1

我有一些来自可绘制 int 数组的图像,现在我想将每个图像从 int 数组转换为 URI。谁能告诉我我该怎么做。提前致谢。这是我的数组

 int mBitmapIds = new int[]{ R.drawable.a, R.drawable.b,
                        R.drawable.c, R.drawable.d };
4

3 回答 3

3
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[);

}
于 2013-06-01T11:48:12.940 回答
1

就像是:

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]);
}
于 2013-06-01T11:48:19.910 回答
0
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;
}
于 2013-06-01T11:47:08.333 回答