Note that there are some explanatory texts on larger screens.

plurals
  1. POWant to exit the application on click of tab
    text
    copied!<p>I am making an application where i have set two bottom tabs,</p> <p>namely "Exit" and "Back".</p> <p>Now i want to exit from the application on the click of the "Exit" tab(not button).</p> <p>How can i do that, i know that in android we can never actually close the application, but i want to go to the Home-screen on clicking "exit".</p> <p>i have studied following link also along with other links</p> <p><a href="https://stackoverflow.com/questions/2033914/quitting-an-application-is-that-frowned-upon/2034238#2034238">Is quitting an application frowned upon?</a></p> <p><strong>EDIT</strong></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(); } 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>
 

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