I have created settings button in Toolbar
, now I need to navigate the screen to settings screen, when ever i click the settings button.
you should override the onCreateOptionsMenu
and onOptionsItemSelected
methods and take that particular id
from menuitem and navigate to settings screen.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.your_menu_xml, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()){
case R.id.action_settings:
Intent i = new Intent(yourActivity.this, SettingsActivity.class)
startActivity(i);
break;
default:
return super.onOptionsItemSelected(item);
}
return super.onOptionsItemSelected(item);
}