In my application I passed the values from page1 to page2 and it is working fine. Now I want to send those values not only from page1 to page2 but also to page3. How can I do that? Please help me regarding this….
Page1
public static final String CATEGORY_KEY = "category";
btn1.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent myIntent = new Intent(Page1.this,
Page2.class);
myIntent.putExtra(CATEGORY_KEY, "10");
startActivityForResult(myIntent, 0);
}
});
btn2.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent myIntent = new Intent(Page1.this,
Page2.class);
myIntent.putExtra(CATEGORY_KEY, "11");
startActivityForResult(myIntent, 0);
}
});
Page2
public static String catgryid;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageView type=(ImageView)findViewById(R.id.imageView1);
Intent intent = getIntent();
catgryid = intent.getStringExtra(Page1.CATEGORY_KEY);
if(catgryid.trim().equals("10"))
{
type.setBackgroundResource(R.drawable.img1);
}
else if(catgryid.trim().equals("11"))
{
type.setBackgroundResource(R.drawable.img2);
}
}
You can always use any of these for it
This link will give you some more details:
http://developer.android.com/resources/faq/framework.html#3