當前位置: 首頁>>代碼示例>>Java>>正文


Java MenuInflater類代碼示例

本文整理匯總了Java中android.view.MenuInflater的典型用法代碼示例。如果您正苦於以下問題:Java MenuInflater類的具體用法?Java MenuInflater怎麽用?Java MenuInflater使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MenuInflater類屬於android.view包,在下文中一共展示了MenuInflater類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCreateOptionsMenu

import android.view.MenuInflater; //導入依賴的package包/類
@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;
}
 
開發者ID:Socialate,項目名稱:furry-sniffle,代碼行數:20,代碼來源:MainActivity.java

示例2: onCreateOptionsMenu

import android.view.MenuInflater; //導入依賴的package包/類
@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;
        }
    });
}
 
開發者ID:fekracomputers,項目名稱:IslamicLibraryAndroid,代碼行數:22,代碼來源:BookCategoryFragment.java

示例3: onCreateOptionsMenu

import android.view.MenuInflater; //導入依賴的package包/類
@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;
}
 
開發者ID:10clouds,項目名稱:InifiniteRecyclerView,代碼行數:19,代碼來源:MainActivity.java

示例4: onCreateOptionsMenu

import android.view.MenuInflater; //導入依賴的package包/類
@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;
}
 
開發者ID:DavidServn,項目名稱:Inventario_Alexa_Android,代碼行數:12,代碼來源:InventoryProvidersActivity.java

示例5: onCreateActionMode

import android.view.MenuInflater; //導入依賴的package包/類
@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;
}
 
開發者ID:CableIM,項目名稱:Cable-Android,代碼行數:19,代碼來源:ConversationListFragment.java

示例6: onPostCreateOptionsMenu

import android.view.MenuInflater; //導入依賴的package包/類
@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);
}
 
開發者ID:axlecho,項目名稱:tuxguitar,代碼行數:8,代碼來源:TGChannelListFragment.java

示例7: onCreateOptionsMenu

import android.view.MenuInflater; //導入依賴的package包/類
@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;
}
 
開發者ID:billthefarmer,項目名稱:editor,代碼行數:19,代碼來源:Editor.java

示例8: onCreateOptionsMenu

import android.view.MenuInflater; //導入依賴的package包/類
@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;
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:20,代碼來源:DetailActivity.java

示例9: onCreateOptionsMenu

import android.view.MenuInflater; //導入依賴的package包/類
@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;
}
 
開發者ID:fjoglar,項目名稱:android-dev-challenge,代碼行數:10,代碼來源:MainActivity.java

示例10: onCreateOptionsMenu

import android.view.MenuInflater; //導入依賴的package包/類
@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);
}
 
開發者ID:WeDevelopTeam,項目名稱:HeroVideo-master,代碼行數:11,代碼來源:HomePageFragment.java

示例11: onCreateOptionsMenu

import android.view.MenuInflater; //導入依賴的package包/類
@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);
}
 
開發者ID:graviton57,項目名稱:DOUSalaries,代碼行數:13,代碼來源:SalaryWidgetFragment.java

示例12: onCreateOptionsMenu

import android.view.MenuInflater; //導入依賴的package包/類
@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;
}
 
開發者ID:MrNo-Body,項目名稱:ecam-app-android,代碼行數:28,代碼來源:FoodDetailsActivity.java

示例13: onCreateOptionsMenu

import android.view.MenuInflater; //導入依賴的package包/類
@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;
            });
}
 
開發者ID:PhoenixDevTeam,項目名稱:Phoenix-for-VK,代碼行數:12,代碼來源:FileManagerFragment.java

示例14: onCreateContextMenu

import android.view.MenuInflater; //導入依賴的package包/類
@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);
  }
}
 
開發者ID:CableIM,項目名稱:Cable-Android,代碼行數:12,代碼來源:VerifyIdentityActivity.java

示例15: onPrepareOptionsMenu

import android.view.MenuInflater; //導入依賴的package包/類
@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);
}
 
開發者ID:majornuts,項目名稱:treehugger,代碼行數:10,代碼來源:BaseActivity.java


注:本文中的android.view.MenuInflater類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。