@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
icon = (ImageView) findViewById(R.id.header);
Resources res = getResources();
// construct the tabhost
setContentView(R.layout.tab_layout);
setupTabHost();
// mTabHost.getTabWidget().setDividerDrawable(R.drawable.hotels);
setupTab(new TextView(this), "Hotels");
res.getDrawable(R.drawable.hote);
setupTab(new TextView(this), "MyAccount");
res.getDrawable(R.drawable.ma);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,
R.layout.tab_layout);
View title = getWindow().findViewById(R.id.tabsLayout);
}
@TargetApi(4)
private void setupTab(final View view, final String tag) {
View tabview = createTabView(mTabHost.getContext(), tag);
TabSpec set_Content = mTabHost.newTabSpec(tag).setIndicator(tabview)
.setContent(new TabContentFactory() {
public View createTabContent(String tag) {
return view;
}
});
switch (tag) {
case ("Hotels"): {
Intent setClass = new Intent(this, ListSample.class);
set_Content.setContent(setClass);
break;
}
case ("MyAccount"): {
/*
* Intent setClass = new Intent(this, AccountActivity.class);
* set_Content.setContent(setClass);
*/break;
}
}
mTabHost.addTab(set_Content);
}
private static View createTabView(final Context context, final String text) {
View view = LayoutInflater.from(context)
.inflate(R.layout.tabs_bg, null);
TextView tv = (TextView) view.findViewById(R.id.tabsText);
tv.setText(text);
return view;
}
}
我正在自定义选项卡并尝试为每个选项卡启动一个活动。我找不到错误。