有人能告诉我如何在 TabActivity 中添加后退按钮方法的监听器吗? 这是我的代码。在哪里添加后退按钮方法?
HomeActivity.java
public class HomeActivity extends TabActivity {
public static TabHost tabHost;
public static TabSpec hometab,extrastab,coursetab,logintab;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.home_tab_layout);
tabHost = getTabHost();
hometab = tabHost.newTabSpec("Home");
hometab.setIndicator("", getResources().getDrawable(R.drawable.home_tab));
hometab.setContent(new Intent().setClass(this,HomeTabActivity.class));
coursetab = tabHost.newTabSpec("Courses");
coursetab.setIndicator("", getResources().getDrawable(R.drawable.courses_tab));
coursetab.setContent(new Intent(this,MainActivity.class));
logintab = tabHost.newTabSpec("Login");
logintab.setIndicator("", getResources().getDrawable(R.drawable.login_tab));
logintab.setContent(new Intent(this,LoginTabActivity.class));
extrastab = tabHost.newTabSpec("Extras");
extrastab.setIndicator("", getResources().getDrawable(R.drawable.extras_tab));
extrastab.setContent(new Intent(this,ExtrasTabActivity.class));
tabHost.addTab(hometab);
tabHost.addTab(coursetab);
tabHost.addTab(logintab);
tabHost.addTab(extrastab);
tabHost.setPadding(5, 5, 5, 5);
}
}
答案 0 :(得分:0)
如何在Activity类中编写onBackPressed()方法? 就像:
public class Tab extends TabActivity {
@Override
public void onBackPressed() {
super.onBackPressed();
}
}