please help me. I am beginner in android java and I stuck with this code.
I have a list item and I want to put exit app button/menu on this.
I just need to run a function to exit app AppExit();
My xml file:
<string-array name="navigation_title_list">
<item>Home</item>
<item>Our Products</item>
<item>References</item>
<item>Support</item>
<item>About Us</item>
<item>Contact</item>
<item>Exit</item>
</string-array>
My java file:
// reference
mDrawerLayout = (DrawerLayout) findViewById(R.id.activity_main_layout);
mDrawerListView = (ListView) findViewById(R.id.activity_main_drawer);
// set drawer
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
mDrawerListView.setAdapter(new DrawerAdapter(this, mTitles, icons));
mDrawerListView.setOnItemClickListener(new OnItemClickListener()
{
@Override
public void onItemClick(AdapterView<?> adapterView, View clickedView, int position, long id)
{
// Here is my exit funtion
AppExit();
selectDrawerItem(position, false);
}
});
I need code something like:
if(<!-- Item value selected == "Exit" -->){
// run exit app funtion
AppExit();
}
Any help will be appreciated. thanks.