本文整理汇总了Java中android.support.v7.view.menu.MenuItemImpl.getActionView方法的典型用法代码示例。如果您正苦于以下问题:Java MenuItemImpl.getActionView方法的具体用法?Java MenuItemImpl.getActionView怎么用?Java MenuItemImpl.getActionView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.view.menu.MenuItemImpl
的用法示例。
在下文中一共展示了MenuItemImpl.getActionView方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: expandItemActionView
import android.support.v7.view.menu.MenuItemImpl; //导入方法依赖的package包/类
public boolean expandItemActionView(MenuBuilder menu, MenuItemImpl item) {
Toolbar.this.ensureCollapseButtonView();
if (Toolbar.this.mCollapseButtonView.getParent() != Toolbar.this) {
Toolbar.this.addView(Toolbar.this.mCollapseButtonView);
}
Toolbar.this.mExpandedActionView = item.getActionView();
this.mCurrentExpandedItem = item;
if (Toolbar.this.mExpandedActionView.getParent() != Toolbar.this) {
LayoutParams lp = Toolbar.this.generateDefaultLayoutParams();
lp.gravity = GravityCompat.START | (Toolbar.this.mButtonGravity & 112);
lp.mViewType = 2;
Toolbar.this.mExpandedActionView.setLayoutParams(lp);
Toolbar.this.addView(Toolbar.this.mExpandedActionView);
}
Toolbar.this.removeChildrenForExpandedActionView();
Toolbar.this.requestLayout();
item.setActionViewExpanded(true);
if (Toolbar.this.mExpandedActionView instanceof CollapsibleActionView) {
((CollapsibleActionView) Toolbar.this.mExpandedActionView).onActionViewExpanded();
}
return true;
}
示例2: createInstanceState
import android.support.v7.view.menu.MenuItemImpl; //导入方法依赖的package包/类
public Bundle createInstanceState() {
Bundle state = new Bundle();
if (this.mCheckedItem != null) {
state.putInt(STATE_CHECKED_ITEM, this.mCheckedItem.getItemId());
}
SparseArray<ParcelableSparseArray> actionViewStates = new SparseArray();
Iterator i$ = this.mItems.iterator();
while (i$.hasNext()) {
NavigationMenuItem navigationMenuItem = (NavigationMenuItem) i$.next();
if (navigationMenuItem instanceof NavigationMenuTextItem) {
MenuItemImpl item = ((NavigationMenuTextItem) navigationMenuItem).getMenuItem();
View actionView = item != null ? item.getActionView() : null;
if (actionView != null) {
ParcelableSparseArray container = new ParcelableSparseArray();
actionView.saveHierarchyState(container);
actionViewStates.put(item.getItemId(), container);
}
}
}
state.putSparseParcelableArray(STATE_ACTION_VIEWS, actionViewStates);
return state;
}
示例3: restoreInstanceState
import android.support.v7.view.menu.MenuItemImpl; //导入方法依赖的package包/类
public void restoreInstanceState(Bundle state) {
Iterator i$;
int checkedItem = state.getInt(STATE_CHECKED_ITEM, 0);
if (checkedItem != 0) {
this.mUpdateSuspended = true;
i$ = this.mItems.iterator();
while (i$.hasNext()) {
NavigationMenuItem item = (NavigationMenuItem) i$.next();
if (item instanceof NavigationMenuTextItem) {
MenuItemImpl menuItem = ((NavigationMenuTextItem) item).getMenuItem();
if (menuItem != null && menuItem.getItemId() == checkedItem) {
setCheckedItem(menuItem);
break;
}
}
}
this.mUpdateSuspended = false;
prepareMenuItems();
}
SparseArray<ParcelableSparseArray> actionViewStates = state.getSparseParcelableArray(STATE_ACTION_VIEWS);
i$ = this.mItems.iterator();
while (i$.hasNext()) {
NavigationMenuItem navigationMenuItem = (NavigationMenuItem) i$.next();
if (navigationMenuItem instanceof NavigationMenuTextItem) {
MenuItemImpl item2 = ((NavigationMenuTextItem) navigationMenuItem).getMenuItem();
View actionView = item2 != null ? item2.getActionView() : null;
if (actionView != null) {
actionView.restoreHierarchyState((SparseArray) actionViewStates.get(item2.getItemId()));
}
}
}
}
示例4: createInstanceState
import android.support.v7.view.menu.MenuItemImpl; //导入方法依赖的package包/类
public Bundle createInstanceState() {
Bundle state = new Bundle();
if (mCheckedItem != null) {
state.putInt(STATE_CHECKED_ITEM, mCheckedItem.getItemId());
}
// Store the states of the action views.
SparseArray<ParcelableSparseArray> actionViewStates = new SparseArray<>();
for (NavigationMenuItem navigationMenuItem : mItems) {
if (navigationMenuItem instanceof NavigationMenuTextItem) {
MenuItemImpl item = ((NavigationMenuTextItem) navigationMenuItem).getMenuItem();
View actionView = item != null ? item.getActionView() : null;
if (actionView != null) {
ParcelableSparseArray container = new ParcelableSparseArray();
actionView.saveHierarchyState(container);
actionViewStates.put(item.getItemId(), container);
}
}
}
state.putSparseParcelableArray(STATE_ACTION_VIEWS, actionViewStates);
return state;
}
示例5: isActionViewOf
import android.support.v7.view.menu.MenuItemImpl; //导入方法依赖的package包/类
/**
* Returns a matcher that matches the action view of the specified menu item.
*
* @param menu The menu
* @param id The ID of the menu item
*/
public static Matcher<View> isActionViewOf(@NonNull final Menu menu, @IdRes final int id) {
return new TypeSafeMatcher<View>() {
private Resources resources;
@Override
protected boolean matchesSafely(View view) {
resources = view.getResources();
MenuItemImpl item = (MenuItemImpl) menu.findItem(id);
return item != null && item.getActionView() == view;
}
@Override
public void describeTo(Description description) {
String name;
if (resources != null) {
name = resources.getResourceName(id);
} else {
name = Integer.toString(id);
}
description.appendText("is action view of menu item " + name);
}
};
}
示例6: createInstanceState
import android.support.v7.view.menu.MenuItemImpl; //导入方法依赖的package包/类
public Bundle createInstanceState() {
Bundle state = new Bundle();
if (checkedItem != null) {
state.putInt(STATE_CHECKED_ITEM, checkedItem.getItemId());
}
// Store the states of the action views.
SparseArray<ParcelableSparseArray> actionViewStates = new SparseArray<>();
for (int i = 0, size = items.size(); i < size; i++) {
NavigationMenuItem navigationMenuItem = items.get(i);
if (navigationMenuItem instanceof NavigationMenuTextItem) {
MenuItemImpl item = ((NavigationMenuTextItem) navigationMenuItem).getMenuItem();
View actionView = item != null ? item.getActionView() : null;
if (actionView != null) {
ParcelableSparseArray container = new ParcelableSparseArray();
actionView.saveHierarchyState(container);
actionViewStates.put(item.getItemId(), container);
}
}
}
state.putSparseParcelableArray(STATE_ACTION_VIEWS, actionViewStates);
return state;
}
开发者ID:material-components,项目名称:material-components-android,代码行数:23,代码来源:NavigationMenuPresenter.java
示例7: createInstanceState
import android.support.v7.view.menu.MenuItemImpl; //导入方法依赖的package包/类
public Bundle createInstanceState() {
Bundle state = new Bundle();
if (mCheckedItem != null) {
state.putInt(STATE_CHECKED_ITEM, mCheckedItem.getItemId());
}
// Store the states of the action views.
SparseArray<ParcelableSparseArray> actionViewStates = new SparseArray<>();
for (int i = 0, size = mItems.size(); i < size; i++) {
NavigationMenuItem navigationMenuItem = mItems.get(i);
if (navigationMenuItem instanceof NavigationMenuTextItem) {
MenuItemImpl item = ((NavigationMenuTextItem) navigationMenuItem).getMenuItem();
View actionView = item != null ? item.getActionView() : null;
if (actionView != null) {
ParcelableSparseArray container = new ParcelableSparseArray();
actionView.saveHierarchyState(container);
actionViewStates.put(item.getItemId(), container);
}
}
}
state.putSparseParcelableArray(STATE_ACTION_VIEWS, actionViewStates);
return state;
}
示例8: getItemView
import android.support.v7.view.menu.MenuItemImpl; //导入方法依赖的package包/类
public View getItemView(MenuItemImpl item, View convertView, ViewGroup parent) {
View actionView = item.getActionView();
if (actionView == null || item.hasCollapsibleActionView()) {
actionView = super.getItemView(item, convertView, parent);
}
actionView.setVisibility(item.isActionViewExpanded() ? 8 : 0);
ActionMenuView menuParent = (ActionMenuView) parent;
LayoutParams lp = actionView.getLayoutParams();
if (!menuParent.checkLayoutParams(lp)) {
actionView.setLayoutParams(menuParent.generateLayoutParams(lp));
}
return actionView;
}
示例9: getActionView
import android.support.v7.view.menu.MenuItemImpl; //导入方法依赖的package包/类
@Nullable
private View getActionView() {
try {
final Field itemData = getClass().getSuperclass().getDeclaredField("mItemData");
itemData.setAccessible(true);
final MenuItemImpl menuImpl = (MenuItemImpl) itemData.get(this);
if (menuImpl == null) return null;
return menuImpl.getActionView();
} catch (Throwable t) {
throw new RuntimeException("Failed to get ActionView from an ActionMenuItemView: " + t.getLocalizedMessage(), t);
}
}