如何从popupwindow上传图像并在android studio中的popupwindow中显示预览?

问题描述 投票:0回答:1

这里试图从弹出窗口执行上载图像,并在从中浏览图像的弹出窗口本身中显示图像的预览。但是我浏览的图像正在上载到服务器,但未在弹出窗口中设置预览。有人可以帮我这个忙吗?

attachCAFiles是显示在弹出窗口中的我的按钮

                        @Override
                        public void onClick(View arg0) {
                            // TODO Auto-generated method stub
                            Intent intent = new Intent(Intent.ACTION_PICK,
                                    android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI);
                            startActivityForResult(intent, GET_FROM_GALLERY_CA);                  

                        }});

在onActivityResult下

 Uri selectedImage = data.getData();
                String result;
                Cursor cursor = getContentResolver().query(selectedImage, null, null, null, null);
                if (cursor == null) { // Source is Dropbox or other similar local file path
                    result = selectedImage.getPath();
                } else {
                    cursor.moveToFirst();
                    int idx = cursor.getColumnIndex(MediaStore.Images.Media.DATA);
                    result = cursor.getString(idx);
                    cursor.close();
                }
 bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), selectedImage);
 LayoutInflater inflater = (LayoutInflater) activity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                    View layout = inflater.inflate(R.layout.actions, null);
                    final ImageView selImage=(ImageView)layout.findViewById(R.id.selectedImage);
                    selImage.setImageBitmap(Bitmap.createScaledBitmap(bitmap, 300,
                            300, false));
                    selImage.setVisibility(View.VISIBLE);
                    final Button imgClose=(Button) layout.findViewById(R.id.closeSelectedImage);
                    imgClose.setVisibility(View.VISIBLE);
                    imgClose.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            databaseHandler.delInspectionFiles(db, String.valueOf(maxId));
                           if (selImage.isShown()){
                               selImage.setBackground(null);
                               selImage.setVisibility(View.GONE);
                           }
                           if (imgClose.isShown()){
                               imgClose.setVisibility(View.GONE);
                           }
                        }
                    });
image android-popupwindow
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.