I was able to pass image view to another layout but once I close the app or change the layout and go back to the layout with the passed image view. The image view disappears. My question is how do I keep the image view inside the layout it was passed too? Here's what I found online to pass image view.
FirstClass.java
RandomImageHere.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), SecondClass.class);
intent.putExtra("resourseInt", R.drawable.picture);
startActivity(intent);
}
});
SecondClass.java
private ImageView imageView;
Bundle extras = getIntent().getExtras();
imageView = (ImageView) findViewById(R.id.image_view);
if (extras == null)
{
return;
}
int res = extras.getInt("resourseInt");
imageView.setImageResource(res);
SecondClass.xml
<ImageView
android:layout_width="90dp"
android:layout_height="90dp"
android:id="@+id/image_view"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true" />