Note that there are some explanatory texts on larger screens.

plurals
  1. POTabhost android
    text
    copied!<p>I am creating simple application which have total 3 activities</p> <ol> <li>sign in- having username, password field and sign in and sign up button</li> <li>sign up- having various form field and submit button</li> <li>Message- after successful sign in we come to this activity</li> </ol> <p>I use tabhost which have 3 tabs defining above 3 activities. On click of tab i can switch between respective activities but when i use buttons on form to switch i can not able to see tabs. I want to show tabs on screen either i switch from tabs or button. Is there any concept like maintaining tab layout and only change activity in frame... I heard about tabhost group but not able to use that...is it possible with that. Tank you </p> <p>my tabhost code is</p> <pre><code>public class TabActivity extends android.app.TabActivity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.tab); /** TabHost will have Tabs */ TabHost tabHost = (TabHost)findViewById(android.R.id.tabhost); /** TabSpec used to create a new tab. * By using TabSpec only we can able to setContent to the tab. * By using TabSpec setIndicator() we can set name to tab. */ /** tid1 is firstTabSpec Id. Its used to access outside. */ TabSpec signinTab = tabHost.newTabSpec("tid1"); TabSpec signupTab = tabHost.newTabSpec("tid2"); TabSpec messageTab = tabHost.newTabSpec("tid3"); /** TabSpec setIndicator() is used to set name for the tab. */ /** TabSpec setContent() is used to set content for a particular tab. */ signinTab.setIndicator("Sign In").setContent(new Intent(getApplicationContext(),SignIn.class)); signupTab.setIndicator("Sign Up").setContent(new Intent(getApplicationContext(),MainActivity.class)); messageTab.setIndicator("Message").setContent(new Intent(getApplicationContext(),MessageDisplay.class)); /** Add tabSpec to the TabHost to display. */ tabHost.addTab(signinTab); tabHost.addTab(signupTab); tabHost.addTab(messageTab);//set Windows tab as default (zero based) // tabHost.setCurrentTab(2); } } </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