当前位置: 首页>>代码示例>>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;未经允许,请勿转载。