انجمن سایت کلیدستان


رتبه موضوع:
  • 0 رای - 0 میانگین
  • 1
  • 2
  • 3
  • 4
  • 5
مشکل در انتقال عکس از گالری به ایمیج ویو (ImageView) (در برنامه نویسی اندروید)

مشکل در انتقال عکس از گالری به ایمیج ویو (ImageView) (در برنامه نویسی اندروید)

#4
سلام

این کد رو برای باز کردن گالری
کد پی‌اچ‌پی:
        gallery.setOnClickListener(new OnClickListener() {
            public 
void onClick(View arg0) {
                
Intent intent = new Intent();
                
intent.setType("image/*");
                
intent.setAction(Intent.ACTION_GET_CONTENT);
                
startActivityForResult(Intent.createChooser(intent,"Select Picture"), SELECT_PICTURE);
            }
        }); 
این کد ریزولت
کد پی‌اچ‌پی:
public void onActivityResult(int requestCodeint resultCodeIntent data) {
        if (
resultCode == RESULT_OK) {
            if (
requestCode == SELECT_PICTURE) {
                
Uri selectedImageUri data.getData();
                
selectedImagePath getPath(selectedImageUri);
                
System.out.println("Image Path : " selectedImagePath);
                
                
display.setImageURI(selectedImageUri);
            }

            
        }
    } 
این هم دریافت آدرس واقعی تصویر
کد پی‌اچ‌پی:
public String getPath(Uri uri) {
        
String[] projection = { MediaStore.Images.Media.DATA };
        
Cursor cursor managedQuery(uriprojectionnullnullnull);
        
int column_index cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
        
cursor.moveToFirst();
        return 
cursor.getString(column_index);
    } 
این کد ها هم قبل از فانکشن اون کریت قرار بدید تعریف متغیر ها
کد پی‌اچ‌پی:
private static final int SELECT_PICTURE 1;
   private 
Uri fileUri;
private 
String selectedImagePath
 

بزودی
پاسخ
 سپاس شده توسط aminem ، داش بهروز


پیام‌های این موضوع
RE: مشکل در انتقال عکس از گالری به ایمیج ویو (ImageView) (در برنامه نویسی اندروید) - توسط seven7up - ۱۳۹۴/۰۷/۱۴, ۱۲:۳۰ ب.ظ

پرش به انجمن:


کاربران در حال بازدید این موضوع: 1 مهمان