我将项目相关图像存储在drawable文件夹中.另外,我将图像名称存储在字符串变量中,并且我正在尝试将这些图像设置为imageview.但图像没有显示.请帮助我这方面.
我的代码:
int res = getResources().getIdentifier(imagename, "drawable", this.getPackageName());
imageview= (ImageView)findViewById(R.id.imageView);
imageview.setImageResource(res);
Run Code Online (Sandbox Code Playgroud)
在上面的代码中,"imagename"是包含图像名称的字符串变量.
提前致谢
我正在研究android应用程序.在我的项目中,我有一个关于签名捕获的任务,即用户应该将他/她的签名保存在移动设备的屏幕上,并且一旦点击了保存按钮,签名就必须存储在数据库中.我搜索并找到了一些链接,但我仍然没有找到确切的解决方案.我也试过TouchPaint.java,但在那里我找不到布局的xml文件.你能用一些示例代码向我们建议吗?我会感激你的....
我login和calendar我的应用程序中有两个活动.目前我的startup活动是" calendar".我想运行第login一个活动而不是calendar.
嗨我已经实现了Fused Location提供程序Api来获取服务中的位置更新.我能够根据间隔设置获取onlocationchanged事件.但是,当我将setsmallestDisplacement设置为10米时,即使设备静止,事件也会被触发.有没有人有类似的问题.请提供建议.下面是代码
mlocationrequest = LocationRequest.create();
mlocationrequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
mlocationrequest.setInterval(60000); // Update location every 1 minute
mlocationrequest.setFastestInterval(10000);
mlocationrequest.setSmallestDisplacement(10);
LocationServices.FusedLocationApi.requestLocationUpdates(
mGoogleApiClient, mlocationrequest, this);
Run Code Online (Sandbox Code Playgroud)
为了找到两个位置值之间的距离,我使用了这种方法.
public static float distFrom (float lat1, float lng1, float lat2, float lng2 )
{
double earthRadius = 3958.75;
double dLat = Math.toRadians(lat2-lat1);
double dLng = Math.toRadians(lng2-lng1);
double a = Math.sin(dLat/2) * Math.sin(dLat/2) +
Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2)) *
Math.sin(dLng/2) * Math.sin(dLng/2);
double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
double dist = earthRadius * c;
int meterConversion = 1609;
return new Float(dist …Run Code Online (Sandbox Code Playgroud) 我需要在android中动态创建edittext字段.我已经浏览了链接,并为其编写了按钮单击操作.那是当我点击按钮时,必须显示复选框.但是当我在onclick操作中创建checkbox对象时,它显示错误.
有人可以告诉我为什么会出现错误?
我的代码:
public class InflationActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ScrollView sv = new ScrollView(this);
final LinearLayout ll = new LinearLayout(this);
ll.setOrientation(LinearLayout.VERTICAL);
sv.addView(ll);
TextView tv = new TextView(this);
tv.setText("Dynamic layouts ftw!");
ll.addView(tv);
EditText et = new EditText(this);
et.setText("weeeeeeeeeee~!");
ll.addView(et);
Button b = new Button(this);
b.setText("I don't do anything, but I was added dynamically. :)");
ll.addView(b);
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
for(int i = …Run Code Online (Sandbox Code Playgroud) 我将我的图像保存在assets文件夹中并尝试显示它们.我试过很多方面,但仍然无法显示图像.在logcat中它没有显示任何错误.
关于这个请帮帮我..........
AssetManager mngr = mContext.getResources().getAssets();
is = mngr.open("test3.png");
bitmap = BitmapFactory.decodeStream(is);
Uri uriSavedImage=Uri.fromFile(pictures_directory);
((ImageView) view.findViewById(R.id.imageView1)).setImageBitmap(bitmap);
Run Code Online (Sandbox Code Playgroud) 我的android应用程序中有两个包.如何在android清单文件中提及那些不同的包及其活动?在我的代码中我给出了
<manifest package="com.tabwidget">
<application>
<activity android:name=".com.tabwidget.Tab"></activity>
<activity android:name=".com.tabwidget.TabHostProvider"></activity>
<activity android:name=".com.tabwidget.TabView"></activity>
</application>
</manifest>
<manifest package="com.kpbird.tabbarcontrol">
<application>
<activity android:name=".com.kpbird.tabbarcontrol.TabbarView"></activity>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
但我得到异常无法找到明确的活动类...........我错在哪里?请帮我...........
我已连接到CPanel并尝试在其中启用PHP的PDO.我已经检查了许多帖子,其中说找到easyApache来启用PDO.但是我无法在我的CPanel Home中找到它.我能找到的是以下功能

请提供有关此问题的建议.谢谢
我使用下面的代码从android联系人中检索名字和姓氏.DISPLAY_NAME给出了联系人的姓名,而firstname和lastname分别返回1和null.以下是代码.
ContentResolver cr = getContentResolver();
Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, null,null, null, null);
if (cur.getCount() > 0) {
while (cur.moveToNext()) {
String id = cur.getString(cur.getColumnIndex(ContactsContract.Contacts._ID));
String name = cur.getString(cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
if (Integer.parseInt(cur.getString(cur.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) > 0) {
Cursor pCur = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,null,ContactsContract.CommonDataKinds.Phone.CONTACT_ID+ " = ?", new String[] { id }, null);
while (pCur.moveToNext()) {
String phoneNo = pCur.getString(pCur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
String firstname = pCur.getString(pCur.getColumnIndex(ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME));
String lastname = pCur.getString(pCur.getColumnIndex(ContactsContract.CommonDataKinds.StructuredName.FAMILY_NAME));
System.out.println("firstname and lastname" + firstname+ " "+lastname);
phoneNo = phoneNo.replaceAll("\\D", "");
names.add(name);
phnno.add(phoneNo);
}
pCur.close();
}
}
}
Run Code Online (Sandbox Code Playgroud)
当我将行cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI)更改为cr.query(ContactsContract.Data.CONTENT_URI)时,我将日志更改为 …
我需要显示客户的详细信息.我需要使用Accordion来显示细节.任何人都可以建议如何在Android中做到这一点?请帮我解决这个问题.