public class test2 extends Activity {
private int TAKE_GALLERY = 1;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.test);
Button btn02 = (Button)findViewById(R.id.Button02);
btn02.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
startActivity(new Intent(test2.this, select.class));
i.setType("image/*");
startActivityForResult(i, TAKE_GALLERY);
}
});
}
}
public class select extends Activity {
/** Called when the activity is first created. */
private Bitmap profileBitmap;
private ImageView profileView;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.select);
profileView =(ImageView)findViewById(R.id.ImageView03);
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
if(resultCode == RESULT_OK){
Uri currImageUri = data.getData();
BitmapFactory.Options bfo = new BitmapFactory.Options();
bfo.inSampleSize = 2;
profileBitmap = BitmapFactory.decodeFile(getRealPathFromURI(currImageUri), bfo);
profileView.setImageBitmap(profileBitmap);
}else if(resultCode != RESULT_OK){
return;
}
}
public String getRealPathFromURI(Uri contentUri){
String []proj = {MediaStore.Images.Media.DATA};
Cursor cursor = managedQuery(contentUri, proj, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
}
}
이런식으로 짯는데 버튼에서 갤러리가 불러와서 이미지가 넘어와야되는데 안넘어와요 ㅠㅠ
고수님들 도와주세요
xml 은 위에 소스는 버튼만있고 2번째소스는 이미지뷰만 있어요
좀더 자세히 설명하면 버튼을 눌렀을때 갤러리가 뜨고 그 버튼과 동일한 이미지뷰에는 나타나기가 가능한데
다른 액티비티(즉, 다음 페이지)에 이미지를 나타낼려고 하니까 안되네요 ㅠㅠ