I am trying to change may current Tab. I search for fitting problems but it not solved my own one.
I have a Tab activity like this
<!-- language: java -->
public class myTabActivity extends TabActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final TabHost mtabHost = getTabHost();
int tabnum = getIntent().getIntExtra("currenttab", 0);
mtabHost.addTab(mtabHost.newTabSpec("tab1")
.setIndicator("firsttab")
.setContent(new Intent(this, tabA.class)));
mtabHost.addTab(mtabHost.newTabSpec("tab1")
.setIndicator("secondtab")
.setContent(new Intent(this, tabB.class)));
setCurrentTab(tabnum);
}
private boolean setCurrentTab(int i) {
if (getParent() instanceof SimpleSundayScoutUIActivity) {
((SimpleSundayScoutUIActivity) getParent()).getTabHost().setCurrentTab(i);
return true;
}
return false;
}
and an activity tabA like this
public class text extends Activity {
myTabActivity mA = (myTabActivity) this.getParent();
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mainpage);
Button startbutton= (Button) findViewById(R.id.searchbutton);
startbutton.setOnClickListener(mNewListener);
}
private OnClickListener mNewListener = new OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(v.getContext(),SimpleSundayScoutUIActivity.class);
intent.putExtra("currenttab", 1);
startActivity(intent);
}
};
means what i want to do is klick on the Button of tabA and then the tab widget should show me tabB but it doesnt work like this
any suggestions?
sry am not really fit in quoting hope it is readable
thanks for help
patrick
edit
mokup for what i want to do http://tinypic.com/r/f6uyq/5
Edited:
Tab class:
Button Class: