Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to prevent starting the activity at the first tab in a TabActivity?
    primarykey
    data
    text
    <p>I have a TabActivity, which contains 4 activities. My code sets the second tab as the current tab:</p> <pre><code>public class MyTabActivity extends TabActivity { TabHost tabHost = getTabHost(); TabHost.TabSpec spec; // Resusable TabSpec for each tab Intent intent; // Reusable Intent for each tab TextView tabView; // Create an Intent to launch an Activity for the tab (to be reused) intent = new Intent().setClass(this, Activity1.class); spec = tabHost.newTabSpec("Tab 1"); spec.setContent(intent); tabView = (TextView) inflater.inflate(R.layout.ff_tab_indicator, null); tabView.setText("Tab 1"); spec.setIndicator(tabView); tabHost.addTab(spec); intent = new Intent().setClass(this, Activity2.class); spec = tabHost.newTabSpec("Tab 2"); spec.setContent(intent); tabView = (TextView) inflater.inflate(R.layout.ff_tab_indicator, null); tabView.setText("Tab 2"); spec.setIndicator(tabView); tabHost.addTab(spec); intent = new Intent().setClass(this, Activity3.class); spec = tabHost.newTabSpec("Tab 3"); spec.setContent(intent); tabView = (TextView) inflater.inflate(R.layout.ff_tab_indicator, null); tabView.setText("Tab 3"); spec.setIndicator(tabView); tabHost.addTab(spec); intent = new Intent().setClass(this, Activity4.class); spec = tabHost.newTabSpec("Tab 4"); spec.setContent(intent); tabView = (TextView) inflater.inflate(R.layout.ff_tab_indicator, null); tabView.setText("Tab 4"); spec.setIndicator(tabView); tabHost.addTab(spec); tabHost.setCurrentTab(1); } </code></pre> <p>The problem is, when the MyTabActivity starts, it starts both activity in the first tab and the activity in the second tab. I just want it to start the activity in the second tab, since it is set to be the current tab. What should I do?</p> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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