当前位置: 首页>>代码示例>>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;未经允许,请勿转载。