我有一些来自可绘制 int 数组的图像,现在我想将每个图像从 int 数组转换为 URI。谁能告诉我我该怎么做。提前致谢。这是我的数组
int mBitmapIds = new int[]{ R.drawable.a, R.drawable.b,
R.drawable.c, R.drawable.d };
Uri[] uris = new Uri[mBitmapIds.lenght];
for (int i = 0; i < mBitmapIds.lenght; i++) {
uris[i] = Uri.parse("android.resource://your.package.here/drawable/"+mBitmpaIds[i[);
}
就像是:
int mBitmapIds = new int[]{ R.drawable.a, R.drawable.b,
R.drawable.c, R.drawable.d };
Uri[] uris = new Uri[4]:
for(int i=0; i<4; i++){
uris[i] = Uri.parse("android.resource://your.package.name/" + mBitmapIds[i]);
}
String PACKAGE="com.yourpackage";
URI getResourceUri(int resId) {
return Uri.parse("android.resource://"+PACKAGE+"/" + resId);
}
URI[] getUris(int[] resIds) {
URI[] uris=new URI[resIds.length];
for (int i=0, len=resIds.length; i<len; i++) uris[i]=getResourceUri(resIds[i]);
return uris;
}