Code example for MenuItem

Methods: getTitle

0
        return super.onPrepareOptionsMenu(menu);
    } 
 
    @Override 
    public boolean onOptionsItemSelected(MenuItem item) {
        Toast.makeText(this, "Selected Item: " + item.getTitle(), Toast.LENGTH_SHORT).show();
        return true; 
    } 
 
    // This method is specified as an onClick handler in the menu xml and will 
    // take precedence over the Activity's onOptionsItemSelected method. 
    // See res/menu/actions.xml for more info. 
    public void onSort(MenuItem item) {
        mSortMode = item.getItemId();
        // Request a call to onPrepareOptionsMenu so we can change the sort icon 
        invalidateOptionsMenu();
    } 
 
    // The following callbacks are called for the SearchView.OnQueryChangeListener 
    // For more about using SearchView, see src/.../view/SearchView1.java and SearchView2.java 
    public boolean onQueryTextChange(String newText) {