If I click on the icon settings, it should create a new activity. But it does show a search popup. Below I post codes and screenshots related to this.


MainActivity.java:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
switch (item.getItemId())
{
case R.id.search:
Intent intent = new Intent(this, SettingsActivity.class);
startActivity(intent);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
main.xml:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" >
<item
android:id="@+id/search"
android:icon="@drawable/ic_action_settings"
android:title="@string/search"/>
</menu>
If I click on this icon, a new action must be created. But it does show a popup search. I do not need this popup. He just needs to switch to a new action by clicking on the icon.So setting far I made such code.
source
share