Note that there are some explanatory texts on larger screens.

plurals
  1. POTabHost with activity
    text
    copied!<p>I built my own TabHost with this code: I have a problem that when i open a new Activity from one of this TabHost's activities so the new activity opened without the TabSelector.</p> <pre><code>public void onCreate(Bundle savedInstanceState) { /*super.onCreate(savedInstanceState); setContentView(R.layout.main); */ super.onCreate(savedInstanceState); this.requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.tabhost); setupTabHost(); mTabHost.getTabWidget().setDividerDrawable(R.drawable.tab_divider); setupTab(new TextView(this), "Search", new Intent(this,Search.class),R.drawable.icon_search); setupTab(new TextView(this), "Info",new Intent(this,Info.class),R.drawable.icon_info); setupTab(new TextView(this), "About", new Intent(this,About.class),R.drawable.icon_about); mTabHost.setCurrentTab(2); } private void setupTab(final View view, final String tag, final Intent i_TagIntent, int i_Icon) { View tabview = createTabView(mTabHost.getContext(), tag,i_Icon); TabSpec setContent = mTabHost.newTabSpec(tag).setIndicator(tabview).setContent( new Intent(i_TagIntent)); mTabHost.addTab(setContent); } private static View createTabView(final Context context, final String text, int i_Icon) { View view = LayoutInflater.from(context).inflate(R.layout.tabs_bg, null); TextView tv = (TextView) view.findViewById(R.id.tabsText); tv.setText(text); ImageView icon = (ImageView) view.findViewById(R.id.tabsIcon); icon.setImageResource(i_Icon); return view; } private void setupTabHost() { mTabHost = (TabHost) findViewById(android.R.id.tabhost); mTabHost.setup(); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload