android开发实践(1)——个人信息设置页面

android开发实践(1)——个人信息设置页面

前言

由于是小组合作,同组的大神已经把大部分的工作的都做好了,我就打打酱油了,添一块砖就好了_

连接真机

  • 手机开发者选项打开USB调试
    • 本人红米4a(对,就是那个499的),进入设置,连续点击关于手机->MIUI版本,开启开发者选项,然后打开更多设置->开发者选项->USB调试即可。
  • 问题:Installation failed with message Failed to establish session.
    It is possible that this issue is resolved by uninstalling an existing version of the apk if it is present, and then re-installing.
    • 解决方法
    1. 手机上 开发者选项里关闭MIUI优化
    2. android studio 中File —— Settings——Build,Execution,Deployment——Instant Run
      (2)将Enable Instant Run to hot swap code/resource changes on deploy(default enabled)的选择框取消

画界面

最顶部头像居中,下面用listview列出各信息

修改头像

  • 调用相册
    (***需权限 < uses-permission android:name=“android.permission.READ_EXTERNAL_STORAGE”/>***)

      public void onClick(View v) {
      //调用相册
      Intent intent = new Intent(Intent.ACTION_PICK,
              android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
      startActivityForResult(intent, 1);
      }
    
  • 上面调用了startActivityForResult,然后利用onActivityResult来对返回的信息进行处理

       @Override
          protected void onActivityResult(int requestCode, int resultCode, Intent data) {
              super.onActivityResult(requestCode, resultCode, data);
              //获取图片路径
              if (requestCode == 1 && resultCode == Activity.RESULT_OK && data != null) {
                  Uri selectedImage = data.getData();
                  String[] filePathColumns = {MediaStore.Images.Media.DATA};
                  Cursor c = getContentResolver().query(selectedImage, filePathColumns, null, null, null);
                  c.moveToFirst();
                  int columnIndex = c.getColumnIndex(filePathColumns[0]);
                  String imagePath = c.getString(columnIndex);
                  showImage(imagePath);
                  c.close();
              }
          }
      
          //加载图片(使用压缩读取技术)
          private void showImage(String imaePath){
              BitmapFactory.Options options = new BitmapFactory.Options();
              options.inJustDecodeBounds = true;
              BitmapFactory.decodeFile(imaePath, options);
              options.inSampleSize = 1;
              int side =  1000;//(int) getResources().getDimension(R.dimen.iv_personal_side);
              int a = options.outWidth/ side;
              options.inSampleSize = a;
              options.inJustDecodeBounds = false;
              Bitmap bm = BitmapFactory.decodeFile(imaePath, options);
              imageView.setImageBitmap(bm);
          }
    

不用压缩,则图片显示不出,报错:Bitmap too large to be uploaded into a texture

  • 4
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值