【#文档大全网# 导语】以下是®文档大全网的小编为您整理的《【推荐下载】Android 由图片资源ID获取图片的文件名》,欢迎阅读!
Android 由图片资源 ID 获取图片的文件名
2011/08/02 2504
@Overrideprotected void onActivityResult(int requestCode, int
resultCode, Intent data) {if (resultCode == RESULT_OK) {Uri uri = data.getData();Cursor cursor = getContentResolver().query(uri, null, null, null,null);cursor.moveToFirst();String imgNo = cursor.getString(0); // 图片编号 String imgPath = cursor.getString(1); // 图片文 件路径 String imgSize = cursor.getString(2); //
图片大小 String imgName =
cursor.getString(3); // 图片文件名// Log.e(“uri”, uri.toString());ContentResolver cr = this.getContentResolver();try
{Bitmap
bitmap
imageView
= =
BitmapFactory.decodeStream(cr.openInputStream(uri));ImageView (ImageView)
findViewById(R.id.imview);/*
catch
将 Bitmap 设定到 ImageView (FileNotFoundException
e)
{//
*/imageView.setImageBitmap(bitmap);}
Log.e(“Exception”, e.getMessage(),e);}}super.onActivityResult(requestCode, resultCode, data);}
tips:感谢大家的阅读,本文由我司收集整编。仅供参阅!
本文来源:https://www.wddqxz.cn/b57607b6f08583d049649b6648d7c1c708a10bb8.html