Note that there are some explanatory texts on larger screens.

plurals
  1. POActivity in TabActivity doesn't run onCreate Method when clicked second time
    primarykey
    data
    text
    <p>I have a <code>TabActivity</code> which includes 3 <code>tabs</code>. And I set <code>currentActivity</code> as <code>1</code> not the default one, <code>0</code> . When I start my <code>TabActivity</code> I figured out that Activity0 also runs but Tabactivity shows the interface of Activity1 which I set as <code>currentActivity</code>. Furthermore when I click tab2 (include Activity2) and click again tba1 or tab0, they dont run again. As I think TabActivity just let to run one time. I would like to restart each activiy in tab whenever I click tabs. And I would like to keep these in trace so that when clicking back button it should be tracable.</p> <pre><code>public class ActivityInTab extends TabActivity implements OnTabChangeListener{ TabHost tabHost; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activityintab); tabHost = getTabHost(); TabSpec meSpec = tabHost.newTabSpec("Ben"); meSpec.setIndicator("Ben", getResources().getDrawable(R.drawable.icon_me)); Intent meIntent = new Intent(this, MeActivity.class); meSpec.setContent(meIntent); TabSpec searchSpec = tabHost.newTabSpec("Arama"); searchSpec.setIndicator("Çevrende Ara", getResources().getDrawable(R.drawable.icon_search)); // Intent searchIntent = new Intent(this, SearchActivity.class); // searchSpec.setContent(searchIntent); TabSpec resultSpec = tabHost.newTabSpec("Aradıklarım"); resultSpec.setIndicator("Arama Sonuçlarım", getResources().getDrawable(R.drawable.icon_result)); // Intent resultIntent = new Intent(this, ResultActivity.class); // resultSpec.setContent(resultIntent); tabHost.addTab(searchSpec); tabHost.addTab(meSpec); tabHost.addTab(resultSpec); tabHost.setCurrentTab(1); tabHost.setOnTabChangedListener(this); } @Override public void onTabChanged(String tabId) { if(tabId.equals("Ben") &amp;&amp; tabHost.getCurrentTab()==0){ MeActivity meact = (MeActivity) getLocalActivityManager().getActivity(tabId); } if(tabId.equals("Arama") &amp;&amp; tabHost.getCurrentTab()==1){ SearchActivity sact= (SearchActivity) getLocalActivityManager().getActivity(tabId); } if(tabId.equals("Aradıklarım") &amp;&amp; tabHost.getCurrentTab()==2){ ResultActivity ract = (ResultActivity) getLocalActivityManager().getActivity(tabId); } } </code></pre> <p>}</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.
 

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