Java Code Examples for android.view.MenuInflater

The following are top voted examples for showing how to use android.view.MenuInflater. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: furry-sniffle   File: MainActivity.java   View source code 7 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.main_menu, menu);

    // Get the SearchView and set the searchable configuration
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.search_btn).getActionView();

    // Assumes current activity is the searchable activity
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default
    searchView.setMaxWidth(Integer.MAX_VALUE);
    searchView.requestFocus(1);
    //searchView.setSubmitButtonEnabled(true);


    return true;
}
 
Example 2
Project: IslamicLibraryAndroid   File: BookCategoryFragment.java   View source code 6 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.fragment_category, menu);
    MenuItem item = menu.findItem(R.id.action_search);
    final SearchView searchView = (SearchView) item.getActionView();
    searchView.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {

            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            mBookCategoryRecyclerViewAdapter.getFilter().filter(newText);
            return true;
        }
    });
}
 
Example 3
Project: InifiniteRecyclerView   File: MainActivity.java   View source code 6 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the options menu from XML
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.options_menu, menu);

    SearchManager searchManager = (SearchManager)
            getSystemService(Context.SEARCH_SERVICE);
    MenuItem searchMenuItem = menu.findItem(R.id.menu_search);
    SearchView searchView = (SearchView) searchMenuItem.getActionView();

    searchView.setSearchableInfo(searchManager.
            getSearchableInfo(getComponentName()));
    searchView.setOnQueryTextListener(this);
    MenuItemCompat.setOnActionExpandListener(searchMenuItem, this);

    return true;
}
 
Example 4
Project: Inventario_Alexa_Android   File: InventoryProvidersActivity.java   View source code 6 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.inventory_providers_menu, menu);
    Drawable drawable = menu.findItem(R.id.inventory_providers_menu_add).getIcon();
    if (drawable != null) {
        drawable.mutate();
        drawable.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP);
    }
    return true;
}
 
Example 5
Project: Cable-Android   File: ConversationListFragment.java   View source code 6 votes vote down vote up
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
  MenuInflater inflater = getActivity().getMenuInflater();

  if (archive) inflater.inflate(R.menu.conversation_list_batch_unarchive, menu);
  else         inflater.inflate(R.menu.conversation_list_batch_archive, menu);

  inflater.inflate(R.menu.conversation_list_batch, menu);

  mode.setTitle(R.string.conversation_fragment_cab__batch_selection_mode);
  mode.setSubtitle(getString(R.string.conversation_fragment_cab__batch_selection_amount, 1));

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    getActivity().getWindow().setStatusBarColor(getResources().getColor(R.color.action_mode_status_bar));
  }

  return true;
}
 
Example 6
Project: tuxguitar   File: TGChannelListFragment.java   View source code 6 votes vote down vote up
@Override
public void onPostCreateOptionsMenu(Menu menu, MenuInflater menuInflater) {
	menuInflater.inflate(R.menu.menu_channel_list, menu);
	
	TGActivity activity = (TGActivity) getActivity();
	TGChannelListMenu.getInstance(this.findContext()).initialize(activity, menu);
}
 
Example 7
Project: editor   File: Editor.java   View source code 6 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.main, menu);

    searchItem = menu.findItem(R.id.search);
    searchView = (SearchView) searchItem.getActionView();

    if (searchView != null)
    {
        searchView.setSubmitButtonEnabled(true);
        searchView.setImeOptions(EditorInfo.IME_ACTION_GO);
        searchView.setOnQueryTextListener(new QueryTextListener());
    }

    return true;
}
 
Example 8
Project: OSchina_resources_android   File: DetailActivity.java   View source code 6 votes vote down vote up
@SuppressLint("SetTextI18n")
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_detail, menu);
    MenuItem item = menu.findItem(R.id.menu_scroll_comment);
    if (item != null) {
        View action = item.getActionView();
        if (action != null) {
            View tv = action.findViewById(R.id.tv_comment_count);
            if (tv != null && mBean != null) {
                mCommentCountView = (TextView) tv;
                if (mBean.getStatistics() != null)
                    mCommentCountView.setText(mBean.getStatistics().getComment() + "");
            }
        }
    }
    return true;
}
 
Example 9
Project: android-dev-challenge   File: MainActivity.java   View source code 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    /* Use AppCompatActivity's method getMenuInflater to get a handle on the menu inflater */
    MenuInflater inflater = getMenuInflater();
    /* Use the inflater's inflate method to inflate our menu layout to this menu */
    inflater.inflate(R.menu.forecast, menu);
    /* Return true so that the menu is displayed in the Toolbar */
    return true;
}
 
Example 10
Project: HeroVideo-master   File: HomePageFragment.java   View source code 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
{
    menu.clear();
    inflater.inflate(R.menu.menu_main, menu);

    // 设置SearchViewItemMenu
    MenuItem item = menu.findItem(R.id.id_action_search);
    mSearchView.setMenuItem(item);
}
 
Example 11
Project: DOUSalaries   File: SalaryWidgetFragment.java   View source code 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.menu_salaries, menu);
    Spinner spinner = (Spinner) MenuItemCompat.getActionView(menu.findItem(R.id.action_category));
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(),
            R.array.array_period_date, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    spinner.setSelection(periodIndex);//set prevision selected period
    spinner.setOnItemSelectedListener(onItemSelectedListener);
}
 
Example 12
Project: ecam-app-android   File: FoodDetailsActivity.java   View source code 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu, menu);
    inflater.inflate(R.menu.search_menu,menu);
    MenuItem item=menu.findItem(R.id.action_search);
    SearchView searchView=(SearchView) item.getActionView();
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener(){

        @Override
        public boolean onQueryTextSubmit(String query){
            destinationClass = FoodSearchActivity.class;
            Intent intent = new Intent(context, destinationClass);

            // Pass info to the FoodSearchActivity
            intent.putExtra("SEARCH_TERM", query.toString());

            startActivity(intent);
            return false;
        }
        public boolean onQueryTextChange(String newText){

            return false;
        }
    });
    return true;
}
 
Example 13
Project: Phoenix-for-VK   File: FileManagerFragment.java   View source code 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    menu.add(R.string.create_dir)
            .setIcon(CurrentTheme.getDrawableFromAttribute(getActivity(), R.attr.toolbarPlusIcon))
            .setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS)
            .setOnMenuItemClickListener(item -> {
                showTextInputDialog();
                return true;
            });
}
 
Example 14
Project: Cable-Android   File: VerifyIdentityActivity.java   View source code 5 votes vote down vote up
@Override
public void onCreateContextMenu(ContextMenu menu, View view,
                                ContextMenuInfo menuInfo)
{
  super.onCreateContextMenu(menu, view, menuInfo);

  if (fingerprint != null) {
    MenuInflater inflater = getActivity().getMenuInflater();
    inflater.inflate(R.menu.verify_display_fragment_context_menu, menu);
  }
}
 
Example 15
Project: treehugger   File: BaseActivity.java   View source code 5 votes vote down vote up
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    if(currentNavigationItem==R.id.map||currentNavigationItem==R.id.heatmap) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.base, menu);
        return true;
    }
    return super.onPrepareOptionsMenu(menu);
}
 
Example 16
Project: orgzly-android   File: QueryFragment.java   View source code 5 votes vote down vote up
@Override
public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
    if (BuildConfig.LOG_DEBUG) LogUtils.d(TAG, actionMode, menu);

    /* Inflate a menu resource providing context menu items. */
    MenuInflater inflater = actionMode.getMenuInflater();
    inflater.inflate(R.menu.query_cab, menu);

    return true;
}
 
Example 17
Project: markor   File: MoreFragment.java   View source code 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.more__menu, menu);
    ContextUtils cu = ContextUtils.get();

    cu.tintMenuItems(menu, true, Color.WHITE);
    cu.setSubMenuIconsVisiblity(menu, true);
}
 
Example 18
Project: Ships   File: ShowMapFragment.java   View source code 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
	menu.setGroupVisible(R.id.main_menu_group_share, true);

	final ShareActionProvider shareActionProvider = (ShareActionProvider) menu.findItem(R.id.menu_share).getActionProvider();
	shareActionProvider.setShareIntent(getShareIntent());
	shareActionProvider.setOnShareTargetSelectedListener(new OnShareTargetSelectedListener() {
		@Override
		public boolean onShareTargetSelected(ShareActionProvider actionProvider, Intent intent) {
           Analytics.getInstance().logEvent(TAG, "share","");
           takeScreenShotWithCheck();
           return false;
		}
	});
}
 
Example 19
Project: buildAPKsSamples   File: ContentFragment.java   View source code 5 votes vote down vote up
public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
    actionMode.setTitle(R.string.photo_selection_cab_title);

    MenuInflater inflater = getActivity().getMenuInflater();
    inflater.inflate(R.menu.photo_context_menu, menu);
    return true;
}
 
Example 20
Project: Linux-notifier-Android   File: MainActivity.java   View source code 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.mainmenu, menu);
    return true;
}
 
Example 21
Project: Nird2   File: DevReportActivity.java   View source code 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
	// Inflate the menu items for use in the action bar
	MenuInflater inflater = getDelegate().getMenuInflater();
	inflater.inflate(R.menu.dev_report_actions, menu);
	sendReport = menu.findItem(R.id.action_send_report);

	return super.onCreateOptionsMenu(menu);
}
 
Example 22
Project: QuranAndroid   File: TranslationReadActivity.java   View source code 5 votes vote down vote up
/**
 * Override function to create or inflate menu
 *
 * @param menu Activity menu
 * @return Menu you create
 */
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_transaltion_read, menu);
    return super.onCreateOptionsMenu(menu);
}
 
Example 23
Project: GitHub   File: FlickrSearchActivity.java   View source code 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
  MenuInflater menuInflater = getMenuInflater();
  menuInflater.inflate(R.menu.search_activity, menu);

  searchView =
      (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.search));
  searchView.setSubmitButtonEnabled(true);
  searchView.setIconified(false);
  searchView.setOnQueryTextListener(this);

  return true;
}
 
Example 24
Project: piast-trail   File: PlaceListFragment.java   View source code 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.fragment_place_list, menu);
    
    MenuItem searchItem = menu.findItem(R.id.action_locate);
    searchItem.setEnabled(mClient.isConnected());
}
 
Example 25
Project: ultrasonic   File: SelectAlbumActivity.java   View source code 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
	MenuInflater inflater = getMenuInflater();
	inflater.inflate(R.menu.select_album, menu);
	super.onCreateOptionsMenu(menu);

	return true;
}
 
Example 26
Project: DAPNETApp   File: CallFragment.java   View source code 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    Log.i(TAG, "Creating menu...");
    inflater.inflate(R.menu.main_menu, menu);

    final MenuItem searchItem = menu.findItem(R.id.action_search);
    final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    searchView.setOnQueryTextListener(this);


}
 
Example 27
Project: boohee_v5.6   File: Fragment.java   View source code 5 votes vote down vote up
boolean performCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    boolean show = false;
    if (this.mHidden) {
        return false;
    }
    if (this.mHasMenu && this.mMenuVisible) {
        show = true;
        onCreateOptionsMenu(menu, inflater);
    }
    if (this.mChildFragmentManager != null) {
        return show | this.mChildFragmentManager.dispatchCreateOptionsMenu(menu, inflater);
    }
    return show;
}
 
Example 28
Project: tumbviewer   File: VideoFragment.java   View source code 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.menu_download_video, menu);
    MenuItem menuItem = menu.findItem(R.id.show_user_video);
    if (showUserVideo) {
        menuItem.setChecked(true);
    } else {
        menuItem.setChecked(false);
    }
    super.onCreateOptionsMenu(menu, inflater);
}
 
Example 29
Project: Guanajoven   File: EmpresaFragment.java   View source code 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.menu_empresas, menu);

    final MenuItem searchItem = menu.findItem(R.id.item_buscar_empresas);
    final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    searchView.setOnQueryTextListener(this);
}
 
Example 30
Project: Swift-Braille-Soft-keyboard   File: DotsStyleActivity.java   View source code 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    try{
        MenuInflater menuInflater = getMenuInflater();
        menuInflater.inflate(R.menu.settings_menu, menu);
    } catch(Exception e){
        e.printStackTrace();
    }

    return super.onCreateOptionsMenu(menu);
}
 
Example 31
Project: EsperantoRadio   File: EoUdsendelse_frag.java   View source code 5 votes vote down vote up
@Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
//    inflater.inflate(R.menu.udsendelse, menu);
    inflater.inflate(R.menu.eo_ludado_menuo, menu);
    //menu.findItem(R.id.hør).setVisible(udsendelse.kanNokHøres).setEnabled(streamsKlar());
    //menu.findItem(R.id.hent).setVisible(DRData.instans.hentedeUdsendelser.virker() && udsendelse.kanNokHøres && udsendelse.hentetStream==null);
  }
 
Example 32
Project: GoSCELE   File: BaseActivity.java   View source code 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    if (findOptionsMenu() != 0) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(findOptionsMenu(), menu);
    }
    return super.onCreateOptionsMenu(menu);
}
 
Example 33
Project: GitHub   File: MainActivity.java   View source code 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_main, menu);

    return true;
}
 
Example 34
Project: AOSP-Kayboard-7.1.2   File: UserDictionaryAddWordFragment.java   View source code 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) {
    final MenuItem actionItemAdd = menu.add(0, OPTIONS_MENU_ADD, 0,
            R.string.user_dict_settings_add_menu_title).setIcon(R.drawable.ic_menu_add);
    actionItemAdd.setShowAsAction(
            MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
    final MenuItem actionItemDelete = menu.add(0, OPTIONS_MENU_DELETE, 0,
            R.string.user_dict_settings_delete).setIcon(android.R.drawable.ic_menu_delete);
    actionItemDelete.setShowAsAction(
            MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
}
 
Example 35
Project: android-analytics   File: MainFragment.java   View source code 5 votes vote down vote up
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
                                ContextMenu.ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    MenuInflater inflater = getActivity().getMenuInflater();
    inflater.inflate(R.menu.context_menu, menu);
}
 
Example 36
Project: Nird2   File: GroupActivity.java   View source code 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
	// Inflate the menu items for use in the action bar
	MenuInflater inflater = getMenuInflater();
	inflater.inflate(R.menu.group_actions, menu);

	revealMenuItem = menu.findItem(R.id.action_group_reveal);
	inviteMenuItem = menu.findItem(R.id.action_group_invite);
	leaveMenuItem = menu.findItem(R.id.action_group_leave);
	dissolveMenuItem = menu.findItem(R.id.action_group_dissolve);
	showMenuItems();

	return super.onCreateOptionsMenu(menu);
}
 
Example 37
Project: firebase-testlab-instr-lib   File: NotesList.java   View source code 5 votes vote down vote up
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) {
    AdapterView.AdapterContextMenuInfo info;
    try {
         info = (AdapterView.AdapterContextMenuInfo) menuInfo;
    } catch (ClassCastException e) {
        Log.e(TAG, "bad menuInfo", e);
        return;
    }

    Cursor cursor = (Cursor) getListAdapter().getItem(info.position);
    if (cursor == null) {
        // For some reason the requested item isn't available, do nothing
        return;
    }

    // Inflate menu from XML resource
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.list_context_menu, menu);
    
    // Set the context menu header
    menu.setHeaderTitle(cursor.getString(COLUMN_INDEX_TITLE));
    
    // Append to the
    // menu items for any other activities that can do stuff with it
    // as well.  This does a query on the system for any activities that
    // implement the ALTERNATIVE_ACTION for our data, adding a menu item
    // for each one that is found.
    Intent intent = new Intent(null, Uri.withAppendedPath(getIntent().getData(), 
                                    Integer.toString((int) info.id) ));
    intent.addCategory(Intent.CATEGORY_ALTERNATIVE);
    menu.addIntentOptions(Menu.CATEGORY_ALTERNATIVE, 0, 0,
            new ComponentName(this, NotesList.class), null, intent, 0, null);
}
 
Example 38
Project: IslamicLibraryAndroid   File: BookPageFragment.java   View source code 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.book_page_fragment, menu);
    MenuItem bookmarkItem = menu.findItem(R.id.action_bookmark_this_page);
    bookmarkItem.setChecked(mIsPageBookmarked);
    setBookMarkIcon(bookmarkItem);
}
 
Example 39
Project: Slide-RSS   File: MainActivity.java   View source code 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_subreddit_overview, menu);
    //Only show the "Share Slide" menu item if the user doesn't have Pro installed
    if (SettingValues.tabletUI) {
        menu.findItem(R.id.share).setVisible(false);
    }
    if (SettingValues.fab) {
        menu.findItem(R.id.hide_posts).setVisible(false);
    }
    return true;
}
 
Example 40
Project: Android-Gank-Share   File: GankBaseFragment.java   View source code 5 votes vote down vote up
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    MenuInflater inflater = mActivity.getMenuInflater();
    if(mData.get(itemNow).type.equals("福利"))
        inflater.inflate(R.menu.menu_girl, menu);
    else
        inflater.inflate(R.menu.menu_item, menu);
}