zoukankan      html  css  js  c++  java
  • Android 由图片资源ID获取图片的文件名

    @Override
     protected 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 = BitmapFactory.decodeStream(cr
          .openInputStream(uri));
        ImageView imageView = (ImageView) findViewById(R.id.imview);
        /* 将Bitmap设定到ImageView */
        imageView.setImageBitmap(bitmap);
       } catch (FileNotFoundException e) {
        // Log.e("Exception", e.getMessage(),e);
       }
      }
      super.onActivityResult(requestCode, resultCode, data);
     }

  • 相关阅读:
    elasticsearch之聚合函数
    elasticsearch之高亮查询
    elasticsearch之查询结果过滤
    elasticsearch之布尔查询
    elasticsearch之分页查询
    elasticsearch 之 排序查询
    elasticsearch 查询 term和match
    WSGI uwsgi wsgiref uWSGI werkzeug
    Django Contenttype组件
    迭代器
  • 原文地址:https://www.cnblogs.com/zhwl/p/2125214.html
Copyright © 2011-2022 走看看