I want to create a custom overflow menu item in my ActionBar in addition at the Setting item like described in the image below:
This will help you. I had coded this for overflow menu
In menu/main.xml file
-
And here is your java code:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar actions click
super.onOptionsItemSelected(item);
if(item.getItemId() == R.id.facebook){
Toast.makeText(Getstarted.this, "Option pressed= facebook",Toast.LENGTH_LONG).show();
}
else if(item.getItemId() == R.id.Youtube){
Toast.makeText(Getstarted.this, "Option pressed= youtube",Toast.LENGTH_LONG).show();
}
else if(item.getItemId() == R.id.Twitter){
Toast.makeText(Getstarted.this, "Option pressed= twitter",Toast.LENGTH_LONG).show();
}
return true;
}