How to get an image from one activity and set it to another

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

How to get an image from one activity and set it to another

Postby powellapps » Wed Jan 20, 2010 12:52 am

I have activity A that opens my main layout screen. The main screen consists of a number of image buttons. When one of these image buttons has been selected it opens activity B. Activity B's layout consists of a table layout of more image buttons. When one of those image buttons is selected from activity B, i want it to then assign its image to whatever image button from activity A that was selected to open and start activity B.

My layout screen for A is a relative layout. Activity B's layout - I just copied the layout from A and added a scrolling table layout, and i didn't change any of the variable id's for the new xml file(do i need to? because problem is the same either way). I did this for cosmetic purposes, otherwise the new layout shows a black background, and i just want it to appear like a floating window that comes up over the new screen, so i could use help with that to.

As of know, activity A opens and i get the image buttons to open activity B, but when you select one of the image buttons from the table layout(activityB), it assigns the image to the selected image button in activity A but only for a second.

The image buttons that start the activities do so with intents. I DO NOT have any onStart() onPause() or onResume() implemented, is that my problem? Or do i need to be trying startActivityForResult() and onActivityResult()???

This is activity B for one of the image buttons in the screen changes to the first activity view with setContentView(R.layout.main), then i define the image button and set its image and start Activity A.

public void onClick(View view){

ImageButton mc = (ImageButton) findViewById(;
Intent myIntent = new Intent(Main.this, Cards.class);

Any help would be appreciated...
Once Poster
Once Poster
Posts: 1
Joined: Thu Jan 14, 2010 7:01 am


Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 2 guests