本文整理匯總了Java中android.support.v4.view.MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT屬性的典型用法代碼示例。如果您正苦於以下問題:Java MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT屬性的具體用法?Java MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT怎麽用?Java MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.support.v4.view.MenuItemCompat
的用法示例。
在下文中一共展示了MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: buildMenu
@Override
public boolean buildMenu(Menu menu, @NonNull MenuInflater inflater) {
inflater.inflate(R.menu.swap_next_search, menu);
MenuItem nextMenuItem = menu.findItem(R.id.action_next);
int flags = MenuItemCompat.SHOW_AS_ACTION_ALWAYS | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT;
MenuItemCompat.setShowAsAction(nextMenuItem, flags);
nextMenuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
getActivity().onAppsSelected();
return true;
}
});
SearchView searchView = new SearchView(getActivity());
MenuItem searchMenuItem = menu.findItem(R.id.action_search);
MenuItemCompat.setActionView(searchMenuItem, searchView);
MenuItemCompat.setShowAsAction(searchMenuItem, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
searchView.setOnQueryTextListener(this);
return true;
}