當前位置: 首頁>>代碼示例>>Java>>正文


Java MenuItem.setOnMenuItemClickListener方法代碼示例

本文整理匯總了Java中android.view.MenuItem.setOnMenuItemClickListener方法的典型用法代碼示例。如果您正苦於以下問題:Java MenuItem.setOnMenuItemClickListener方法的具體用法?Java MenuItem.setOnMenuItemClickListener怎麽用?Java MenuItem.setOnMenuItemClickListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.view.MenuItem的用法示例。


在下文中一共展示了MenuItem.setOnMenuItemClickListener方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCreateOptionsMenu

import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.main, menu);

    MenuItem menuItem = menu.findItem(R.id.write_message);
    Utils.setMenuIconTint(getContext(), menuItem, R.attr.colorAccent);
    menuItem.setVisible(true);
    menuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            // open SMS sending activity
            CustomFragmentActivity.show(getContext(),
                    getString(R.string.New_message),
                    SMSSendFragment.class, null);
            return true;
        }
    });

    super.onCreateOptionsMenu(menu, inflater);
}
 
開發者ID:kaliturin,項目名稱:BlackList,代碼行數:21,代碼來源:SMSConversationsListFragment.java

示例2: buildMenu

import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public boolean buildMenu(Menu menu, @NonNull MenuInflater inflater) {

    inflater.inflate(R.menu.swap_next_search, menu);
    MenuItem nextMenuItem = menu.findItem(R.id.action_next);
    int flags = MenuItemCompat.SHOW_AS_ACTION_ALWAYS | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT;
    MenuItemCompat.setShowAsAction(nextMenuItem, flags);
    nextMenuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            getActivity().onAppsSelected();
            return true;
        }
    });

    SearchView searchView = new SearchView(getActivity());

    MenuItem searchMenuItem = menu.findItem(R.id.action_search);
    MenuItemCompat.setActionView(searchMenuItem, searchView);
    MenuItemCompat.setShowAsAction(searchMenuItem, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);

    searchView.setOnQueryTextListener(this);
    return true;
}
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:25,代碼來源:SelectAppsView.java

示例3: onCreateOptionsMenu

import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    if (showReloadPlacesButton) {
        getMenuInflater().inflate(R.menu.main_menu, menu);
        final MenuItem myActionMenuItem = menu.findItem(R.id.action_refresh);
        myActionMenuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
                PlaceFragment placeFragment = (PlaceFragment) getSupportFragmentManager().findFragmentById(R.id.fragment_container);
                if (placeFragment.isAdded()) {
                    placeFragment.currentPlace();
                }
                return false;
            }
        });
    }
    return super.onCreateOptionsMenu(menu);
}
 
開發者ID:OpenLocate,項目名稱:openlocate-android,代碼行數:19,代碼來源:MainActivity.java

示例4: onCreateOptionsMenu

import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.main, menu);

    MenuItem menuItem = menu.findItem(R.id.write_message);
    Utils.setMenuIconTint(getContext(), menuItem, R.attr.colorAccent);
    menuItem.setVisible(true);
    menuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            // open activity with fragment of sending SMS
            openSMSSendActivity(contactName, contactNumber, messageEdit.getText().toString());
            messageEdit.setText("");
            return true;
        }
    });

    super.onCreateOptionsMenu(menu, inflater);
}
 
開發者ID:kaliturin,項目名稱:BlackList,代碼行數:20,代碼來源:SMSConversationFragment.java

示例5: onCreateOptionsMenu

import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.example_menu_drawer, menu);

    final MenuItem menuItem = menu.findItem(R.id.toggle_example_toolbar);
    menuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            drawerLayout.onMenuItemClick();
            return true;
        }
    });

    drawerLayout.setViewsClickableAction(new Action1<Boolean>() {
        @Override
        public void execute(Boolean isEnabled) {
            menuItem.setEnabled(isEnabled);
        }
    });

    return true;
}
 
開發者ID:ABTSoftware,項目名稱:SciChart.Android.Examples,代碼行數:23,代碼來源:ExampleActivity.java

示例6: showToc

import android.view.MenuItem; //導入方法依賴的package包/類
protected void showToc() {
    Map<String,String> tocmap = book.getToc();
    PopupMenu tocmenu = new PopupMenu(this, findViewById(R.id.contents_button));
    for (final String point: tocmap.keySet()) {
        String text = tocmap.get(point);
        MenuItem m = tocmenu.getMenu().add(text);
        //Log.d("EPUB", "TOC2: " + text + ". File: " + point);
        m.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem menuItem) {
                handleLink(point);
                return true;
            }
        });
    }
    if (tocmap.size()==0) {
        tocmenu.getMenu().add(R.string.no_toc_found);
    }

    tocmenu.show();

}
 
開發者ID:quaap,項目名稱:BookyMcBookface,代碼行數:23,代碼來源:ReaderActivity.java

示例7: onLongClick

import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public boolean onLongClick(final View v) {

    PopupMenu p = new PopupMenu(this, v);
    MenuItem m = p.getMenu().add("Delete");

    m.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            list.removeView(v);
            db.deleteWebSite((String)v.getTag());
            return true;
        }
    });
    p.show();
    return true;
}
 
開發者ID:quaap,項目名稱:BookyMcBookface,代碼行數:18,代碼來源:GetBooksActivity.java

示例8: onCreateOptionsMenu

import android.view.MenuItem; //導入方法依賴的package包/類
/**
 * Create menu items such as "delete" button
 * @param menu The menu
 * @return
 */
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    final MenuItem deleteItem = menu.add(
            Menu.NONE, DELETE_BUTTON_ID, Menu.NONE, "Delete");
    MenuItemCompat.setShowAsAction(
            deleteItem, MenuItem.SHOW_AS_ACTION_IF_ROOM);
    deleteItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem menuItem) {
            confirmDelete();
            return true;
        }
    });
    return true;
}
 
開發者ID:CMPUT301F17T13,項目名稱:cat-is-a-dog,代碼行數:21,代碼來源:ViewHabitActivity.java

示例9: resolveActionMode

import android.view.MenuItem; //導入方法依賴的package包/類
/**
 * 處理item,處理點擊
 * @param actionMode
 */
private ActionMode resolveActionMode(ActionMode actionMode) {
    if (actionMode != null) {
        final Menu menu = actionMode.getMenu();
        mActionMode = actionMode;
        menu.clear();
        for (int i = 0; i < mActionList.size(); i++) {
            menu.add(mActionList.get(i));
        }
        for (int i = 0; i < menu.size(); i++) {
            MenuItem menuItem = menu.getItem(i);
            menuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    getSelectedData((String) item.getTitle());
                    releaseAction();
                    return true;
                }
            });
        }
    }
    mActionMode = actionMode;
    return actionMode;
}
 
開發者ID:CarGuo,項目名稱:CustomActionWebView,代碼行數:28,代碼來源:CustomActionWebView.java

示例10: onCreateOptionsMenu

import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
	super.onCreateOptionsMenu(menu);

	MenuItem reset = menu.add(R.string.menu_colors_reset);
	reset.setAlphabeticShortcut('r');
	reset.setNumericShortcut('1');
	reset.setIcon(android.R.drawable.ic_menu_revert);
	reset.setOnMenuItemClickListener(new OnMenuItemClickListener() {
		public boolean onMenuItemClick(MenuItem arg0) {
			// Reset each individual color to defaults.
			for (int i = 0; i < Colors.defaults.length; i++) {
				if (mColorList[i] != Colors.defaults[i]) {
					mHostDb.setGlobalColor(i, Colors.defaults[i]);
					mColorList[i] = Colors.defaults[i];
				}
			}
			mColorGrid.invalidateViews();

			// Reset the default FG/BG colors as well.
			mFgSpinner.setSelection(HostDatabase.DEFAULT_FG_COLOR);
			mBgSpinner.setSelection(HostDatabase.DEFAULT_BG_COLOR);
			mHostDb.setDefaultColorsForScheme(HostDatabase.DEFAULT_COLOR_SCHEME,
					HostDatabase.DEFAULT_FG_COLOR, HostDatabase.DEFAULT_BG_COLOR);

			return true;
		}
	});

	return true;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:32,代碼來源:ColorsActivity.java

示例11: buildMenu

import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public boolean buildMenu(Menu menu, @NonNull MenuInflater inflater) {
    inflater.inflate(R.menu.swap_skip, menu);
    MenuItem next = menu.findItem(R.id.action_next);
    MenuItemCompat.setShowAsAction(next,
            MenuItemCompat.SHOW_AS_ACTION_ALWAYS | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT);
    next.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            getActivity().showWifiQr();
            return true;
        }
    });
    return true;
}
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:16,代碼來源:NfcView.java

示例12: buildMenu

import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public boolean buildMenu(Menu menu, @NonNull MenuInflater inflater) {
    inflater.inflate(R.menu.swap_next, menu);
    MenuItem next = menu.findItem(R.id.action_next);
    MenuItemCompat.setShowAsAction(next,
            MenuItemCompat.SHOW_AS_ACTION_ALWAYS | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT);
    next.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            getActivity().showSelectApps();
            return true;
        }
    });
    return true;
}
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:16,代碼來源:JoinWifiView.java

示例13: setupDialog

import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public void setupDialog(Dialog dialog, int style) {
    super.setupDialog(dialog, style);

    View root = View.inflate(getActivity(), R.layout.sheet_filter_edirt, null);

    Toolbar toolbar = root.findViewById(R.id.toolbar);
    toolbar.setTitle(R.string.search_options);

    MenuItem saveItem = toolbar.getMenu().add(R.string.save);
    saveItem.setIcon(CurrentTheme.getDrawableFromAttribute(getActivity(), R.attr.toolbarOKIcon));
    saveItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    saveItem.setOnMenuItemClickListener(menuItem -> {
        onSaveClick();
        return true;
    });

    mEmptyText = root.findViewById(R.id.empty_text);

    RecyclerView mRecyclerView = root.findViewById(R.id.recycler_view);

    RecyclerView.LayoutManager manager = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
    mRecyclerView.setLayoutManager(manager);

    mAdapter = new SearchOptionsAdapter(mData);
    mAdapter.setOptionClickListener(this);

    mRecyclerView.setAdapter(mAdapter);
    resolveEmptyTextVisibility();

    dialog.setContentView(root);
}
 
開發者ID:PhoenixDevTeam,項目名稱:Phoenix-for-VK,代碼行數:33,代碼來源:FilterEditFragment.java

示例14: onPrepareOptionsMenu

import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    MenuItem actionViewItem = menu.findItem(R.id.btn_removeVehicle_bar);
    actionViewItem.setTitle(getString(R.string.update));
    actionViewItem.setOnMenuItemClickListener(this);
    return super.onPrepareOptionsMenu(menu);
}
 
開發者ID:piskula,項目名稱:FuelUp,代碼行數:8,代碼來源:EditVehicleActivity.java

示例15: selectFontSize

import android.view.MenuItem; //導入方法依賴的package包/類
private void selectFontSize() {
    final int defsize = webView.getSettings().getDefaultFontSize();
    int minsize = webView.getSettings().getMinimumFontSize();
    final float scale = getResources().getDisplayMetrics().density;


   // Log.d("READER", "def " + defsize + " " + scale);
    final PopupMenu sizemenu = new PopupMenu(this, findViewById(R.id.zoom_button));
    for (int size=minsize; size<=36; size+=2) {
        final int s = size;

        MenuItem mi = sizemenu.getMenu().add(" "+size);
        mi.setCheckable(true);
        mi.setChecked(size==defsize);

        mi.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem menuItem) {
                Log.d("READER", "def " + (defsize-s));
                int scrolloffset = (int)(-webView.getScrollY()*(defsize - s)/scale/2.7);
                Log.d("READER", "scrollby " + scrolloffset);

                setFontSize(s);

                //attempt to adjust the scroll to keep the same text position.
                //  needs much work
                webView.scrollBy(0, scrolloffset);
                sizemenu.dismiss();
                return true;
            }
        });
    }
    sizemenu.show();


}
 
開發者ID:quaap,項目名稱:BookyMcBookface,代碼行數:37,代碼來源:ReaderActivity.java


注:本文中的android.view.MenuItem.setOnMenuItemClickListener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。