有时,当我想将值引用到字符串引用时,我使用@ string/blabla,但有时,它会给我一个错误,我可以运行代码,除非我改变@string to @+string
它们之间有什么区别?任何答案都会非常有帮助.提前致谢!
在我的Android应用程序中,我试图从他的Facebook帐户获取用户的封面照片.
我可以使用下面的代码获取个人资料图片.
profilePicUrl = new URL("http://graph.facebook.com/" + userId + "/picture?type=large");
profilePicBmp = BitmapFactory.decodeStream(profilePicUrl.openConnection().getInputStream());
Run Code Online (Sandbox Code Playgroud)
该文档指定了以下用于检索封面照片.
用户的封面照片(必须使用fields = cover参数明确请求)
需要access_token
返回:字段数组id,source和offset_y
因此,JSON响应的结构将是这样的.
{
"cover": {
"cover_id": "10151008748223553",
"source": "http://sphotos-a.ak.fbcdn.net/hphotos-ak-ash4/s720x720/391237_10151008748223553_422785532_n.jpg",
"offset_y": 0
},
"id": "19292868552"
}
Run Code Online (Sandbox Code Playgroud)
我是Facebook Graph API的新手,因此对如何解决这个问题知之甚少.
我试过这个 coverPicUrl = new URL("http://graph.facebook.com/" + userId + "/cover?type=large");
还有这个 coverPicUrl = new URL("http://graph.facebook.com/" + userId + "/fields=cover");
但我无法获得用户个人资料的封面图片.
在线搜索也没有取得任何丰硕成果.
任何帮助确实会受到赞赏.
谢谢!
我正在努力实现这样的目标.可扩展列表由某些类别的名称组成,单击父级时,它会显示该类别中所有子级的列表.现在,假设我想动态地将孩子添加到任何类别?我怎么做 ?我是否按下列表中的每个父母点击一个按钮,在其下面添加一个新的孩子?
但是在不同的论坛中,我开始意识到在每个父级中设置按钮点击处理程序并不容易.但如果这是唯一的方法,有人可以给我一些示例代码吗?
我找到了这个帖子但是无法在我的代码中实现它. 使用Button,Android Row变为Unclickable
我对一个Bitmap对象进行了一些处理(质量改进和一些调整大小),然后bitmap.compress()通过给出一个文件名"myfile.png" 来使用函数存储它.
newbitmap = processImage(bitmap);
FileOutputStream fos = context.openFileOutput("myfile.png", Context.MODE_PRIVATE);
newbitmap.compress(CompressFormat.PNG, 100, fos);
Run Code Online (Sandbox Code Playgroud)
现在我想加载这个图像,ImageView但我不能用setImageBitmap()它来做.还有其他选择吗?
我无法使用的原因setImageBitmap()是我正在使用RemoteViews一个小部件,并且当图像很大时,使用位图方法会导致Failed Binder Transaction错误.
我尝试使用下面的代码设置图像uri,但图像不会加载到ImageView:
RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.widget_layout);
File internalFile = context.getFileStreamPath("myfile.png");
Uri internal = Uri.fromFile(internalFile);
rv.setImageViewUri(R.id.widgetImageView, internal);
updateAppWidget(awID, rv);
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助!
如何在另一个活动中访问变量值.在我的例子中,我有一个字符串变量项,其值是微调器选择的值.如何在不使用Intent的情况下在另一个活动中访问此变量?
public class LoginScreen extends Activity {
Spinner sp;
String item;
Spinner sp = (Spinner) findViewById(R.id.lgnspinner);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
this, R.array.network_array,
android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
sp.setAdapter(adapter);
sp.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View view,
int position, long id) {
item = (String) parent.getItemAtPosition(position);
public class AgAppMenu extends Activity {
Run Code Online (Sandbox Code Playgroud) 我们正在为开发Android应用程序的单个应用程序创建许多XML文件; 当然这是android的主题.对于app的每个屏幕,我们都在创建一个带有一些布局的XML(静态实现).在执行时,每次读取XML文件以获取它想要显示我们设计的屏幕的所有资源.
通过在java代码本身中添加几行(动态实现)可以实现相同的设计.就像我们可以扩展ListActivity而不是创建XML文件一样.那么为什么要使用XML,因为应用程序需要从手机内存中读取文件,这可能导致访问速度慢并使应用程序变慢?
因此,动态实现总是优于静态实现.
如果我错了,请纠正我.
嗨,我正在开发一个创建动态组件,如按钮等的应用程序.当某种情况发生时,我想删除或清空我的布局..任何人都可以指导或建议我吗?
我正在开发一个应用程序,从图库中选择一个图像,然后将该图像设置为壁纸.但这里的问题是只有部分图像被设置为壁纸而不是整个图像,但我想将整个图像设置为壁纸.你能告诉我怎么办?
这是我的代码......
public class Scaleimage extends Activity {
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
String FileName;
File file = new File("/sdcard/pictures");
File[] imageFiles = file.listFiles( );
if(imageFiles.length > 0 ) {
FileName = imageFiles[0].getName();
final WallpaperManager wallpaperManager = WallpaperManager.getInstance(getBaseContext());
Bitmap myBitmap = BitmapFactory.decodeFile("/sdcard/pictures" + "/" + FileName);
DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
int height = displayMetrics.heightPixels;
int width = displayMetrics.widthPixels << 1;
myBitmap = Bitmap.createScaledBitmap(myBitmap,width, height, true);
try { …Run Code Online (Sandbox Code Playgroud) 当我使用这种方法时,我会回到登录页面,但我仍然可以点击返回按钮,它会将我返回到上一个活动.为什么不关闭其他活动?
public void restartApplication() {
Intent i = getBaseContext().getPackageManager().getLaunchIntentForPackage(getBaseContext().getPackageName());
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
}
Run Code Online (Sandbox Code Playgroud)
有没有办法完成除登录活动之外的所有活动?或重新启动整个应用程序?
例如android正在使用仿生而不是glibc,但如何弄清楚它真的是使用仿生http://en.wikipedia.org/wiki/Bionic_(software),而不是glibc?
我可以在/ proc文件系统中找到这些信息,或者是否有任何命令可以告诉bionic在当前系统中使用?
顺便说一句,嵌入式系统可能有多个c lib吗?