Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>you can use this code</p> <pre><code>public class Man_age_ur_PhoneActivity extends TabActivity { /** Called when the activity is first created. */ ListView listview; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.homepage); setTabs(); getTabHost().setOnTabChangedListener(new OnTabChangeListener() { @Override public void onTabChanged(String tabId) { int i = getTabHost().getCurrentTab(); Log.i("@@@@@@@@ ANN CLICK TAB NUMBER", "------" + i); if (i == 0) { Log.i("@@@@@@@@@@ Inside onClick tab 0", "onClick tab"); } else if (i ==1) { Log.i("@@@@@@@@@@ Inside onClick tab 1", "onClick tab"); } } }); } private void setTabs() { addTab("Exit", R.drawable.tab_exit); addTab("Back", R.drawable.tab_back); //To add more tabs just use addTab() method here like previous line. } private void addTab(String labelId, int drawableId) { TabHost tabHost = getTabHost(); // Intent intent = new Intent(this, c); TabHost.TabSpec spec = tabHost.newTabSpec("" + labelId); View tabIndicator = LayoutInflater.from(this).inflate(R.layout.tab_indicator, getTabWidget(), false); TextView title = (TextView) tabIndicator.findViewById(R.id.title); title.setText(labelId); ImageView icon = (ImageView) tabIndicator.findViewById(R.id.icon); icon.setImageResource(drawableId); spec.setIndicator(tabIndicator); // spec.setContent(intent); tabHost.addTab(spec); } } </code></pre> <p>Also import this </p> <pre><code>import android.widget.TabHost; import android.widget.TabHost.OnTabChangeListener; </code></pre> <p>Taken from this link <a href="https://stackoverflow.com/questions/4337514/android-tabwidget-detect-click-on-current-tab">Android TabWidget detect click on current tab</a></p>
 

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