Java 类android.view.MenuInflater 实例源码

项目:IslamicLibraryAndroid    文件:BookCategoryFragment.java   
@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;
        }
    });
}
项目:InifiniteRecyclerView    文件:MainActivity.java   
@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;
}
项目:Cable-Android    文件:ConversationListFragment.java   
@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;
}
项目:editor    文件:Editor.java   
@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;
}
项目:OSchina_resources_android    文件:DetailActivity.java   
@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;
}
项目:furry-sniffle    文件:MainActivity.java   
@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;
}
项目:android-dev-challenge    文件:MainActivity.java   
@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;
}
项目:HeroVideo-master    文件:HomePageFragment.java   
@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);
}
项目:DOUSalaries    文件:SalaryWidgetFragment.java   
@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);
}
项目:ecam-app-android    文件:FoodDetailsActivity.java   
@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;
}
项目:Phoenix-for-VK    文件:FileManagerFragment.java   
@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;
            });
}
项目:Cable-Android    文件:VerifyIdentityActivity.java   
@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);
  }
}
项目:treehugger    文件:BaseActivity.java   
@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);
}
项目:orgzly-android    文件:QueryFragment.java   
@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;
}
项目:markor    文件:MoreFragment.java   
@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);
}
项目:Ships    文件:ShowMapFragment.java   
@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;
        }
    });
}
项目:buildAPKsSamples    文件:ContentFragment.java   
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;
}
项目:Linux-notifier-Android    文件:MainActivity.java   
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.mainmenu, menu);
    return true;
}
项目:Inventario_Alexa_Android    文件:InventoryProvidersActivity.java   
@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;
}
项目:Nird2    文件:DevReportActivity.java   
@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);
}
项目:QuranAndroid    文件:TranslationReadActivity.java   
/**
 * 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);
}
项目:GitHub    文件:FlickrSearchActivity.java   
@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;
}
项目:piast-trail    文件:PlaceListFragment.java   
@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());
}
项目:ultrasonic    文件:SelectAlbumActivity.java   
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.select_album, menu);
    super.onCreateOptionsMenu(menu);

    return true;
}
项目:DAPNETApp    文件:CallFragment.java   
@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);


}
项目:boohee_v5.6    文件:Fragment.java   
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;
}
项目:tumbviewer    文件:VideoFragment.java   
@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);
}
项目:Guanajoven    文件:EmpresaFragment.java   
@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);
}
项目:Swift-Braille-Soft-keyboard    文件:DotsStyleActivity.java   
@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);
}
项目:tuxguitar    文件:TGChannelListFragment.java   
@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);
}
项目:EsperantoRadio    文件:EoUdsendelse_frag.java   
@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);
  }
项目:GoSCELE    文件:BaseActivity.java   
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    if (findOptionsMenu() != 0) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(findOptionsMenu(), menu);
    }
    return super.onCreateOptionsMenu(menu);
}
项目:GitHub    文件:MainActivity.java   
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_main, menu);

    return true;
}
项目:AOSP-Kayboard-7.1.2    文件:UserDictionaryAddWordFragment.java   
@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);
}
项目:android-analytics    文件:MainFragment.java   
@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);
}
项目:Nird2    文件:GroupActivity.java   
@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);
}
项目:firebase-testlab-instr-lib    文件:NotesList.java   
@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);
}
项目:IslamicLibraryAndroid    文件:BookPageFragment.java   
@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);
}
项目:Slide-RSS    文件:MainActivity.java   
@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;
}
项目:Android-Gank-Share    文件:GankBaseFragment.java   
@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);
}