I am using TabHost with 3 tabs. I need to pass the params selected from one screen using Bundle and / or Intent to the next and then set the correct tab in TabHost and pass those params to the correct tab. I hope that makes sense. I have a config screen that has several radio buttons that are grouped and 1 checkbox and a button. in my onClick() I have the following code.
public class Distribute extends Activity implements OnClickListener {
DistributionMap gixnav;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView textview = new TextView(this);
textview.setText("Distribution");
setContentView(R.drawable.configup);
Button button = (Button)findViewById(R.id.btn_configup1);
button.setOnClickListener(this);
}
public void onClick(View v) {
Intent intent;
Bundle extras = new Bundle();
intent = new Intent().setClass(getApplicationContext(), Clevel.class);
intent.putExtras(extras);
startActivity(intent);
}
}
I need to pass the selection params (which radio button is selected and is the checkbox clicked to Clevel. In Clevel I have to parse the bundle and operate on those params. Basiclaly I will be pulling data froma DB and using that data to call google maps ItemizedOverlay.
onClick calls Clevel.class using Intent. This works and I understand how Intent works. What I need to understand is how to grab or reference the selected radio button and whatever else may be clicked or checked and pass it through TabHost to the correct Tab. This is what I have in Clevel for TabHost. From TabHost the onCLick will need to pass everything to Distribute.class
public class Clevel extends TabActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.gixout1);
Resources res = getResources();
TabHost tabHost = getTabHost();
TabHost.TabSpec spec;
Intent intent;
String mData;
Bundle extras = getIntent().getExtras();
if (extras != null) {
mData = extras.getString("key");
}
intent = new Intent().setClass(this, ClevelMain.class);
spec = tabHost.newTabSpec("Main").setIndicator("C-Level",
res.getDrawable(R.drawable.gixmain))
.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, Distribute.class);
spec = tabHost.newTabSpec("Config").setIndicator("Distribute",
res.getDrawable(R.drawable.gixconfig))
.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, DistributionMap.class);
spec = tabHost.newTabSpec("Nav").setIndicator("Map",
res.getDrawable(R.drawable.gixnav))
.setContent(intent);
tabHost.addTab(spec);
tabHost.setCurrentTab(3);
tabHost.getOnFocusChangeListener();
}
I am really looking for some pointers on how to pass and use params in Bundle and whether in should use Bundle and Intent or can I just use Intent?
Thanks in advance, Pat
This will be useful for you
Sharing data between tabs...