本文整理了Java中android.app.Activity.getMenuInflater()
方法的一些代码示例,展示了Activity.getMenuInflater()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Activity.getMenuInflater()
方法的具体详情如下:
包路径:android.app.Activity
类名称:Activity
方法名:getMenuInflater
暂无
代码示例来源:origin: aurelhubert/ahbottomnavigation
/**
* Constructor
*
* @param activity
* @param menuRes
*/
public AHBottomNavigationAdapter(Activity activity, @MenuRes int menuRes) {
PopupMenu popupMenu = new PopupMenu(activity, null);
mMenu = popupMenu.getMenu();
activity.getMenuInflater().inflate(menuRes, mMenu);
}
代码示例来源:origin: code-mc/material-icon-lib
public static MaterialMenuInflater with(Context context){
return new MaterialMenuInflater(
context,
context instanceof Activity ?
((Activity)context).getMenuInflater()
: new MenuInflater(context)
);
}
代码示例来源:origin: stackoverflow.com
public class MyMenuHandler {
private Activity mActivity;
public MyMenuHandler(Activity activity) {
mActivity = activity;
}
public boolean onPrepareOptionsMenu(Menu menu) {
MenuInflater inflater = mActivity.getMenuInflater();
menu.clear();
inflater.inflate(R.menu.gv_options_menu, menu);
return true;
}
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.view:
...
}
}
}
代码示例来源:origin: iqiyi/Neptune
@Override
public android.view.MenuInflater getMenuInflater() {
return mOriginActivity.getMenuInflater();
}
代码示例来源:origin: com.uphyca/android-junit4-robolectric
/**
* @return
* @see android.app.Activity#getMenuInflater()
*/
public MenuInflater getMenuInflater() {
return mActivity.getMenuInflater();
}
代码示例来源:origin: RealMoMo/Study_Android_Demo
@Override
public MenuInflater getMenuInflater() {
return mProxyActivity.getMenuInflater();
}
代码示例来源:origin: BuildmLearn/BuildmLearn-Toolkit-Android
/**
* {@inheritDoc}
*/
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
if (showTemplateSelectedMenu) {
activity.getMenuInflater().inflate(R.menu.menu_project_selected, menu);
} else {
activity.getMenuInflater().inflate(R.menu.menu_apk_not_selected, menu);
}
}
代码示例来源:origin: BuildmLearn/BuildmLearn-Toolkit-Android
/**
* {@inheritDoc}
*/
@Override
public void onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
if (showTemplateSelectedMenu) {
activity.getMenuInflater().inflate(R.menu.menu_apk_selected, menu);
} else {
activity.getMenuInflater().inflate(R.menu.menu_apk_not_selected, menu);
}
}
代码示例来源:origin: VREMSoftwareDevelopment/WiFiAnalyzer
public void create(@NonNull Activity activity, Menu menu) {
activity.getMenuInflater().inflate(R.menu.optionmenu, menu);
this.menu = menu;
iconsVisible(menu);
}
代码示例来源:origin: BuildmLearn/BuildmLearn-Toolkit-Android
/**
* {@inheritDoc}
*/
@Override
public void onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
menu.clear();
if (showTemplateSelectedMenu) {
activity.getMenuInflater().inflate(R.menu.menu_project_selected, menu);
menu.findItem(R.id.action_share).setVisible(false);
} else if (mAdapter.getCount() > 0) {
activity.getMenuInflater().inflate(R.menu.menu_draft, menu);
}
}
代码示例来源:origin: apsun/NekoSMS
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
MenuInflater inflater = getActivity().getMenuInflater();
inflater.inflate(R.menu.context_filter_rules, menu);
menu.setHeaderTitle(R.string.filter_actions);
}
代码示例来源:origin: apsun/NekoSMS
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
MenuInflater inflater = getActivity().getMenuInflater();
inflater.inflate(R.menu.context_blocked_messages, menu);
menu.setHeaderTitle(R.string.message_actions);
}
代码示例来源:origin: ybonnel/TransportsRennes
@Override
public boolean onCreateOptionsMenu(Menu menu) {
if (resourceMenu == -1) {
return false;
}
mActivity.getMenuInflater().inflate(resourceMenu, menu);
if (mActivity instanceof Searchable) {
SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
searchView.setOnQueryTextListener(new OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
((Searchable) mActivity).updateQuery(newText);
return true;
}
});
}
return true;
}
代码示例来源:origin: milosmns/silly-android
/**
* {@inheritDoc}
*/
@Override
@SuppressLint("ResourceType") // TODO getLayoutId() can return < 0 ???
public boolean onCreateOptionsMenu(@NonNull final Menu menu) {
super.onCreateOptionsMenu(menu);
if (getMenuId() > 0 && getOwnerActivity() != null) {
getOwnerActivity().getMenuInflater().inflate(getMenuId(), menu);
return true;
}
return false;
}
代码示例来源:origin: grzegorznittner/chanu
@Override
protected boolean onCreateActionBar(Menu menu) {
GalleryActionBar actionBar = mActivity.getGalleryActionBar();
actionBar.setDisplayShowHomeEnabled(true);
actionBar.setDisplayHomeAsUpEnabled(true);
MenuInflater inflater = ((Activity) mActivity).getMenuInflater();
inflater.inflate(R.menu.photo, menu);
if (menu == null)
return true;
mMenu = menu;
mShowBars = true;
updateMenuOperations();
return true;
}
代码示例来源:origin: CloudRail/cloudrail-si-android-sdk
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
selectedItem = view;
selectedItemPosition = position;
PopupMenu popupMenu = new PopupMenu(context, view);
MenuInflater menuInflater = ((Activity)context).getMenuInflater();
menuInflater.inflate(R.menu.selected_bucket_bar, popupMenu.getMenu());
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_delete_bucket: {
removeItem();
return true;
}
default:
return false;
}
}
});
popupMenu.show();
return true;
}
});
代码示例来源:origin: CloudRail/cloudrail-si-android-sdk
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
selectedItem = view;
selectedItemPosition = position;
PopupMenu popupMenu = new PopupMenu(context, view);
MenuInflater menuInflater = ((Activity)context).getMenuInflater();
menuInflater.inflate(R.menu.selected_file_bar, popupMenu.getMenu());
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_delete_file: {
removeItem();
return true;
}
case R.id.action_download_file: {
downloadItem();
return true;
}
default:
return false;
}
}
});
popupMenu.show();
return true;
}
});
代码示例来源:origin: VREMSoftwareDevelopment/WiFiAnalyzer
@Test
public void testCreate() {
// setup
when(activity.getMenuInflater()).thenReturn(menuInflater);
// execute
fixture.create(activity, menu);
// validate
assertEquals(menu, fixture.getMenu());
verify(menuInflater).inflate(R.menu.optionmenu, menu);
}
代码示例来源:origin: SamuelGjk/GComic
public void inflateMenu(@MenuRes int menuRes) {
if (menuRes == 0) return;
getActivity().getMenuInflater()
.inflate(menuRes, mActionMenu.getMenu());
XmlResourceParser parser = null;
try {
//noinspection ResourceType
parser = getResources().getLayout(menuRes);
AttributeSet attrs = Xml.asAttributeSet(parser);
parseMenu(parser, attrs);
} catch (XmlPullParserException | IOException e) {
// should not happens
throw new InflateException("Error parsing menu XML", e);
} finally {
if (parser != null) parser.close();
}
}
代码示例来源:origin: DF1E/SimpleExplorer
@Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
menu.clear();
mActivity.getMenuInflater().inflate(R.menu.actionmode, menu);
if (mActivity instanceof SearchActivity) {
menu.removeItem(R.id.actiongroupowner);
menu.removeItem(R.id.actionrename);
menu.removeItem(R.id.actionzip);
if (mListView.getCheckedItemCount() > 1) {
menu.removeItem(R.id.actiondetails);
}
} else {
if (!Settings.rootAccess())
menu.removeItem(R.id.actiongroupowner);
if (mListView.getCheckedItemCount() > 1) {
menu.removeItem(R.id.actionrename);
menu.removeItem(R.id.actiongroupowner);
menu.removeItem(R.id.actiondetails);
}
}
return true;
}
内容来源于网络,如有侵权,请联系作者删除!