۱۳۹۴/۰۶/۰۲, ۰۵:۱۶ ب.ظ
(۱۳۹۴/۰۶/۰۲, ۰۴:۱۹ ب.ظ)'kousha.nikkar' نوشته: سلام من کد زیر رو دارم که میتونه یک تصویر رو از آلبوم انتخای کنه...
و حالا میخوام این کد رو بذارم توی یک دکمه که وقتی روی دکمه کلیک شد انجام بشه...کد پیاچپی:@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK && null != data) {
Uri selectedImage = data.getData();
String filePathColumn = { MediaStore.Images.Media.DATA };
Cursor cursor = getContentResolver().query(selectedImage,filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String picturePath = cursor.getString(columnIndex);
Toast.makeText(getApplicationContext(), picturePath, Toast.LENGTH_LONG).show();
cursor.close();
// ImageView imageView = (ImageView) findViewById(R.id.imageView1);
// imageView.setImageBitmap(BitmapFactory.decodeFile(picturePath));
}
}
چطور این کار رو انجام بدم؟؟؟؟
سلام :
شما مسیر عکس رو گرفتی یعنی بیشتر کار را انجام دادی(picturepath)
فقط کافی است که pcturepath را در داخل یک string سراسری بریزی بعد button خودت رو تعریف کن و بعد داخل رویداد کلیک کردن باتن دو دستور که کامنت کردی رو بنویس .