I want to pass extra to my NextActivity so that a button in NextActivity can have different intents. I am successful with doing this to view different layouts, but no clue on how to do this on a button.
Heres the code that has a working setContentView switch;
public class ContentViewer extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle bundle = this.getIntent().getExtras();
int chooser = bundle.getInt("Layout");
switch(chooser) {
case 0:
setContentView(R.layout.about);
break;
case 1:
setContentView(R.layout.contact);
break;
case 2:
setContentView(R.layout.contentviewer);
break;
case 3:
setContentView(R.layout.contact);
break;
case 4:
setContentView(R.layout.contact);
break;
case 5:
setContentView(R.layout.contact);
break;
case 6:
setContentView(R.layout.contact);
break;
case 7:
setContentView(R.layout.contact);
break;
case 8:
setContentView(R.layout.contact);
break;
case 9:
setContentView(R.layout.contact);
break;
}
}
}
Now, in these layouts, there is a button with the same ID, but i want it to have different Intents based on different cases(like the setContentView above).
UPDATE
Theres MainActivity, it has a listview that passes extra. When an item in the listview is clicked, it will open the NextActivity(like in code). NextActivity has a layout that has a Button. Now, based on which item was clicked on the MainActivity, the Button will have different Intents. For example, if in MainActivity, item 1 was clicked, open NextActivity, override Button to have intent 1. If in MainActivity item 2 was clicked, open NextActivity with override button to have intent 2 INSTEAD of intent 1. Clear enough?
Something like this you may need to be: