本文整理汇总了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;
}
示例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;
}
});
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
});
}
示例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);
}
}
示例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);
}