我有两个不同的活动,但有不同的图像。当我单击图像时,我要扩展。我可以使用一个XML文件来显示来自不同活动的这些图像吗?
我已经通过意图将图像从两个活动传递到一个XML活动,并使用if else语句打开被点击的图像。但是对于这两个活动,仅显示一个活动的图像。
public class FullImageActivity extends Activity {
ImageView imageView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.full_image);
imageView = findViewById(R.id.fullImageView);
motivation = findViewById(R.id.motivation);
depression = findViewById(R.id.depression);
stress = findViewById(R.id.stress);
study = findViewById(R.id.study);
Intent intent = getIntent();
int position = intent.getExtras().getInt("id");
depression.imageAdapter imageAdapter = new depression.imageAdapter(this);
Intent intent1 = getIntent();
int position1 = intent1.getExtras().getInt("id");
motivation.imageAdapter1 imageAdapter1 = new motivation.imageAdapter1(this);
if(imageAdapter.isEnabled()){
imageView.setImageResource(imageAdapter.mThumbIds[position]);
}else {
imageView.setImageResource(imageAdapter1.mThumbIds1[position1]);
}
}
}