MenuItem getTitle - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for MenuItem getTitle method.

This code example shows how to use the following methods:getTitle
//        return true; 
//    } 
 
    @Override 
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.getTitle().equals("TEST DATA")) {
            Database.getDB().createTestData(this);
        } else { 
            Database.getDB().createDemoData(this);
        } 
        if (fragment != null) {
            fragment.reload();
        } 
        return true; 
    } 
 
    public void reload() { 
        if (fragment != null) {
            fragment.reload();
        } 
6
CodeRank
This code example shows how to use the following methods:getTitle
        PopupMenu popup = new PopupMenu(this, button);
        popup.getMenuInflater().inflate(R.menu.popup, popup.getMenu());
 
        popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
            public boolean onMenuItemClick(MenuItem item) {
                Toast.makeText(PopupMenu1.this, "Clicked popup menu item " + item.getTitle(),
                        Toast.LENGTH_SHORT).show();
                return true; 
            } 
        }); 
 
        popup.show();
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getTitle
        return true; 
    } 
 
    @Override 
    public boolean onOptionsItemSelected(MenuItem item) {
        Toast.makeText(this, "Selected Item: " + item.getTitle(), Toast.LENGTH_SHORT).show();
        return true; 
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getTitle
        return true; 
    } 
 
    private class MenuHandler implements MenuItem.OnMenuItemClickListener {
        public boolean onMenuItemClick(MenuItem item) {
            return onTextContextMenuItem(item.getTitle());
        } 
    } 
 
    public boolean onTextContextMenuItem(CharSequence title) {
        boolean handled = false;
        if (TextUtils.equals(title, mMenuItemsStrings[CUT])) {
            cutContent(); 
            handled = true;
        } else if (TextUtils.equals(title,  mMenuItemsStrings[COPY])) {
            copyContent(); 
            handled = true;
        } else if (TextUtils.equals(title,  mMenuItemsStrings[PASTE])) {
            pasteContent(); 
            handled = true;
6
CodeRank
This code example shows how to use the following methods:getTitle
        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 
6
CodeRank
This code example shows how to use the following methods:getTitle
        return true; 
    } 
 
    @Override 
    public boolean onOptionsItemSelected(MenuItem item) {
        Toast.makeText(this, "Selected Item: " + item.getTitle(), Toast.LENGTH_SHORT).show();
        return true; 
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getGroupId, getTitle
        return true; 
    } 
     
    @Override 
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getGroupId()) {
        case PATCH_GID:
            setPatch(item.getTitle().toString());
            setRange(2,6); 
            return true; 
        case SCALE_GID:
            setScale(item.getTitle().toString().toLowerCase());
            return true; 
        case KEY_GID:
            setKey(item.getItemId());
            return true; 
        default: 
            return super.onOptionsItemSelected(item);
        } 
    } 
5
CodeRank
This code example shows how to use the following methods:getTitle
        return true; 
    } 
 
    private class MenuHandler implements MenuItem.OnMenuItemClickListener {
        public boolean onMenuItemClick(MenuItem item) {
            return onTextContextMenuItem(item.getTitle());
        } 
    } 
 
    public boolean onTextContextMenuItem(CharSequence title) {
        boolean handled = false;
        if(TextUtils.equals(title, mMenuItemsStrings[CUT])) {
            cutContent(); 
            handled = true;
        } 
        else if(TextUtils.equals(title, mMenuItemsStrings[COPY])) {
            copyContent(); 
            handled = true;
        } 
        else if(TextUtils.equals(title, mMenuItemsStrings[PASTE])) {
5
CodeRank
This code example shows how to use the following methods:getTitle
		return menuItem.getSubMenu();
	} 
 
	@Override 
	public CharSequence getTitle() {
		return menuItem.getTitle();
	} 
 
	@Override 
	public CharSequence getTitleCondensed() {
		return menuItem.getTitleCondensed();
	} 
 
	@Override 
	public boolean hasSubMenu() { 
		return menuItem.hasSubMenu();
	} 
 
	@Override 
	public boolean isActionViewExpanded() { 
5
CodeRank
This code example shows how to use the following methods:getMenuInfo, getTitle
        e.clear();
    } 
     
    @Override 
    public boolean onContextItemSelected(MenuItem item) {
        if (item.getTitle() == "Delete") {
            AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
            removeAttribute(info.position);
        } 
         
        return super.onContextItemSelected(item);     
    } 
     
    @Override 
    public void onCreateContextMenu(ContextMenu menu, View v,
            ContextMenuInfo menuInfo) {
         
        menu.setHeaderTitle("Attribute");
        menu.add("Delete");
        menu.add("Cancel");
5
CodeRank

Related MenuItem getTitle Questions & Answers:

getTitle Method Overview
Retrieve the current title of the item.
See Code Examples for other Android MenuItem Methods: