我有两个背靠背的图像视图。当我在第一个图像视图上设置图像时,它也会在下一个图像视图上设置相同的图像,当我从一个图像视图更改图像时,它也会从其他图像更改该图像。我该如何修复它。请帮我。先感谢您。相关代码为:
` ImageView cpic,psymbol;
private static final int PICK_IMAGE=100;
private static final int SET_IMAGE=100;
Uri imageUri,simageUri;
cpic.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openGallery();
}
});
psymbol.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openGallary();
}
});
}
private void openGallery() {
Intent Gallery = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.INTERNAL_CONTENT_URI);
startActivityForResult(Gallery,PICK_IMAGE);
}
private void openGallary(){
Intent Gallary = new Intent(Intent.ACTION_PICK,MediaStore.Images.Media.INTERNAL_CONTENT_URI);
startActivityForResult(Gallary,SET_IMAGE);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode==RESULT_OK && requestCode==PICK_IMAGE){
imageUri=data.getData();
InputStream imageinput = null;
try {
imageinput=getContentResolver().openInputStream(imageUri);
cpic.setImageBitmap(BitmapFactory.decodeStream(imageinput));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
if (resultCode==RESULT_OK && requestCode==SET_IMAGE){
simageUri=data.getData();
InputStream inputimage = null;
try {
inputimage=getContentResolver().openInputStream(simageUri);
psymbol.setImageBitmap(BitmapFactory.decodeStream(inputimage));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}
ITMISS
MMMHUHU
相关分类