对于资源URI,格式为:
"android.resource://package/res id“
package是您的包名
res ID是资源id的值,例如R.drawable.sample_1
但是,我将使用什么作为平台资源的包。例如,我想要平台资源的URI,它是最受欢迎的明星。
非常感谢,
发布于 2012-04-30 17:52:54
平台资源的包名是"android",因此star_big_on Android平台可绘制文件的URI是"android.resource://android/" + android.R.drawable.star_big_on。
下面是在ImageView中显示该URI的活动的代码:
package com.example.android;
import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.widget.ImageView;
public class ExampleActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Setup an ImageView to display the resource URI with
ImageView v = new ImageView(this);
setContentView(v);
// Set the URI to an Android platform resource
Uri uri = Uri.parse("android.resource://android/" + android.R.drawable.star_big_on);
v.setImageURI(uri);
}
}运行该活动将如下所示:

https://stackoverflow.com/questions/10322190
复制相似问题