Answer the question
In order to leave comments, you need to log in
How to fix error when adding menu items?
I want to add 2 menu items
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
MenuItem searchItem = menu.findItem(R.id.action_search);
SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
searchView.setQueryHint("Поиск");
searchView.setOnQueryTextListener(this);
return true;
MenuItem item = (MenuItem) menu.findItem(R.id.action_share);
ShareActionProvider shareAction = (ShareActionProvider) MenuItemCompat
.getActionProvider(item);
Intent shareIntent = new Intent(Intent.ACTION_SEND)
.setAction(Intent.ACTION_SEND)
.putExtra(Intent.EXTRA_TEXT, "а")
.setType("text/plain");
shareAction.setShareIntent(shareIntent);
return super.onCreateOptionsMenu(menu);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question