Skip to content

Instantly share code, notes, and snippets.

@wightwulf1944
Created January 8, 2018 12:58
Show Gist options
  • Save wightwulf1944/51879f13768d1c1905d2e29976d1f96d to your computer and use it in GitHub Desktop.
Save wightwulf1944/51879f13768d1c1905d2e29976d1f96d to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/searchAction"
android:icon="@drawable/ic_search"
android:title="Search"
app:actionViewClass="android.support.v7.widget.SearchView"
app:showAsAction="always"/>
</menu>
import android.support.v7.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main_action, menu);
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment