我知道此前有很多关于此的问题,但我有点失落......
这是我的tabhost活动代码:
@SuppressWarnings("deprecation")
public class ManagerActivity extends ActivityGroup implements OnTabChangeListener {
private TabHost th;
private Intent Tab1Intent;
private Intent Tab2Intent;
private Intent Tab3Intent;
private Intent Tab4Intent;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.manager);
th = (TabHost) findViewById(android.R.id.tabhost);
th.setup(this.getLocalActivityManager());
InitTabs(th);
th.setOnTabChangedListener(this);
}
private void InitTabs(TabHost th){
TabSpec specs = th.newTabSpec("tag1");
specs.setIndicator("עדכון הודעות");
Tab1Intent= new Intent(this, UpdateMessagesActivity.class);
specs.setContent(Tab1Intent);
th.addTab(specs);
specs = th.newTabSpec("tag2");
specs.setIndicator("עדכון אירועים");
Tab2Intent = new Intent(this, UpdateEventsActivity.class);
specs.setContent(Tab1Intent);
th.addTab(specs);
specs = th.newTabSpec("tag3");
specs.setIndicator("עדכון זמני השבת");
Tab3Intent = new Intent(this, updateShabathTimesActivity.class);
specs.setContent(Tab1Intent);
th.addTab(specs);
specs = th.newTabSpec("tag4");
specs.setIndicator("עדכון זמני יום חול");
Tab4Intent = new Intent(this, UpdateDaysTimesActivity.class);
specs.setContent(Tab1Intent);
th.addTab(specs);
th.setCurrentTab(0);
}
@Override
public void onTabChanged(String tabId) {
// TODO Auto-generated method stub
if(tabId.equals("tag1")){
// now what??
}else if(tabId.equals("tag2")){
// now what??
}else if(tabId.equals("tag3")){
// now what??
}else{
// now what??
}
}
}
你可以看到,我真的不知道在OnTabChanged方法中该怎么做...... 我需要一个很好的解释(有例子)。
谢谢你们。