List of usage examples for android.view MenuInflater MenuInflater
public MenuInflater(Context context)
From source file:com.royclarkson.springagram.GalleryPhotoListFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); MenuInflater inflater = new MenuInflater(this.getActivity()); inflater.inflate(R.menu.gallery_photo_list_context_menu, menu); }
From source file:com.dattasmoon.pebble.plugin.IgnorePreference.java
@Override protected void onBindDialogView(View view) { btnAdd = (Button) view.findViewById(R.id.btnAdd); etMatch = (EditText) view.findViewById(R.id.etMatch); chkRawRegex = (CheckBox) view.findViewById(R.id.chkRawRegex); chkCaseInsensitive = (CheckBox) view.findViewById(R.id.chkCaseInsensitive); actvApplications = (AutoCompleteTextView) view.findViewById(R.id.actvApplications); spnApplications = (Spinner) view.findViewById(R.id.spnApplications); spnMode = (Spinner) view.findViewById(R.id.spnMode); lvIgnore = (ListView) view.findViewById(R.id.lvIgnore); lvIgnore.setAdapter(arrayAdapter);// ww w. j a v a2 s .com lvIgnore.setEmptyView(view.findViewById(android.R.id.empty)); new LoadAppsTask().execute(); lvIgnore.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() { @Override public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) { AdapterView.AdapterContextMenuInfo contextInfo = (AdapterView.AdapterContextMenuInfo) menuInfo; int position = contextInfo.position; long id = contextInfo.id; // the child view who's info we're viewing (should be equal to v) final View v = contextInfo.targetView; MenuInflater inflater = new MenuInflater(getContext()); inflater.inflate(R.menu.preference_ignore_context, menu); //we have to do this mess because DialogPreference doesn't allow for onMenuItemSelected or onOptionsItemSelected. Bleh menu.findItem(R.id.btnEdit).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { final int arrayPosition = (Integer) v.getTag(); final String text = ((TextView) v.findViewById(R.id.tvItem)).getText().toString(); JSONArray temp = new JSONArray(); for (int i = 0; i < arrayAdapter.getJSONArray().length(); i++) { try { JSONObject ignore = arrayAdapter.getJSONArray().getJSONObject(i); if (i == arrayPosition) { etMatch.setText(ignore.getString("match")); chkRawRegex.setChecked(ignore.getBoolean("raw")); chkCaseInsensitive.setChecked(ignore.optBoolean("insensitive", true)); String app = ignore.getString("app"); if (app == "-1") { actvApplications.setText(getContext().getString(R.string.ignore_any)); } else { actvApplications.setText(app); } boolean exclude = ignore.optBoolean("exclude", true); if (exclude) { spnMode.setSelection(Constants.IgnoreMode.EXCLUDE.ordinal()); } else { spnMode.setSelection(Constants.IgnoreMode.INCLUDE.ordinal()); } continue; } temp.put(ignore); } catch (JSONException e) { e.printStackTrace(); } } arrayAdapter.setJSONArray(temp); arrayAdapter.notifyDataSetChanged(); return true; } }); menu.findItem(R.id.btnDelete).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { AlertDialog.Builder builder = new AlertDialog.Builder(v.getContext()); final int arrayPosition = (Integer) v.getTag(); final String text = ((TextView) v.findViewById(R.id.tvItem)).getText().toString(); builder.setMessage(getContext().getResources().getString(R.string.confirm_delete) + " '" + text + "' ?") .setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { JSONArray temp = new JSONArray(); for (int i = 0; i < arrayAdapter.getJSONArray().length(); i++) { if (i == arrayPosition) { continue; } try { temp.put(arrayAdapter.getJSONArray().getJSONObject(i)); } catch (JSONException e) { e.printStackTrace(); } } arrayAdapter.setJSONArray(temp); arrayAdapter.notifyDataSetChanged(); } }).setNegativeButton(R.string.decline, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // User cancelled the dialog } }); builder.create().show(); return true; } }); } }); btnAdd.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { JSONObject item = new JSONObject(); try { item.put("match", etMatch.getText().toString()); item.put("raw", chkRawRegex.isChecked()); item.put("insensitive", chkCaseInsensitive.isChecked()); if (actvApplications.getText().toString() .equalsIgnoreCase(getContext().getString(R.string.ignore_any))) { item.put("app", "-1"); } else { item.put("app", actvApplications.getText().toString()); } if (spnMode.getSelectedItemPosition() == Constants.IgnoreMode.INCLUDE.ordinal()) { item.put("exclude", false); } else { item.put("exclude", true); } if (Constants.IS_LOGGABLE) { Log.i(Constants.LOG_TAG, "Item is: " + item.toString()); } arrayAdapter.getJSONArray().put(item); etMatch.setText(""); arrayAdapter.notifyDataSetChanged(); } catch (JSONException e) { e.printStackTrace(); } } }); actvApplications.setText(getContext().getString(R.string.ignore_any)); actvApplications.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { actvApplications.showDropDown(); } }); actvApplications.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { ApplicationInfo pkg = (ApplicationInfo) parent.getItemAtPosition(position); if (pkg == null) { actvApplications.setText(getContext().getString(R.string.ignore_any)); } else { actvApplications.setText(pkg.packageName); } } }); actvApplications.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { actvApplications.showDropDown(); } else { if (actvApplications.getText().length() == 0) { actvApplications.setText(getContext().getString(R.string.ignore_any)); } } } }); super.onBindDialogView(view); }
From source file:com.shinymayhem.radiopresets.FragmentStations.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); new MenuInflater(mContext).inflate(R.menu.station_selected, menu); }
From source file:org.openintents.filemanager.FileManagerActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = new MenuInflater(this); inflater.inflate(R.menu.main, menu); return true;/*from w ww .j a v a2s .co m*/ }
From source file:com.urbantamil.projmadurai.BookListActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater mnu = new MenuInflater(getApplicationContext()); if (inBookmarkMode() || inRecentBookMode()) { mnu.inflate(R.menu.clear_menu, menu); } else {// ww w. j a v a2s . c o m mnu.inflate(R.menu.sort_menu, menu); } return super.onCreateOptionsMenu(menu); }
From source file:com.royclarkson.springagram.PhotoListFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); MenuInflater inflater = new MenuInflater(this.getActivity()); inflater.inflate(R.menu.photo_list_context_menu, menu); }
From source file:org.mozilla.gecko.home.HomeFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) { if (!(menuInfo instanceof HomeContextMenuInfo)) { return;//w w w . j a v a 2s .c o m } HomeContextMenuInfo info = (HomeContextMenuInfo) menuInfo; // Don't show the context menu for folders. if (info.isFolder) { return; } MenuInflater inflater = new MenuInflater(view.getContext()); inflater.inflate(R.menu.home_contextmenu, menu); menu.setHeaderTitle(info.getDisplayTitle()); // Hide unused menu items. menu.findItem(R.id.top_sites_edit).setVisible(false); menu.findItem(R.id.top_sites_pin).setVisible(false); menu.findItem(R.id.top_sites_unpin).setVisible(false); // Hide the "Edit" menuitem if this item isn't a bookmark, // or if this is a reading list item. if (!info.hasBookmarkId() || info.isInReadingList()) { menu.findItem(R.id.home_edit_bookmark).setVisible(false); } // Hide the "Remove" menuitem if this item not removable. if (!info.canRemove()) { menu.findItem(R.id.home_remove).setVisible(false); } if (!StringUtils.isShareableUrl(info.url) || GeckoProfile.get(getActivity()).inGuestMode()) { menu.findItem(R.id.home_share).setVisible(false); } if (!RestrictedProfiles.isAllowed(view.getContext(), Restriction.DISALLOW_PRIVATE_BROWSING)) { menu.findItem(R.id.home_open_private_tab).setVisible(false); } }
From source file:net.survivalpad.android.ArticleEditActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater menuInflater = new MenuInflater(this); menuInflater.inflate(R.menu.article_edit, menu); return super.onCreateOptionsMenu(menu); }
From source file:com.kanedias.vanilla.lyrics.LyricsShowActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = new MenuInflater(this); inflater.inflate(R.menu.lyrics_options, menu); return super.onCreateOptionsMenu(menu); }
From source file:com.ushahidi.android.app.ui.phone.AddCheckinActivity.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); new MenuInflater(this).inflate(R.menu.photo_context, menu); }