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


Java ActionMenuView類代碼示例

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


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

示例1: setOverflowButtonColor

import android.support.v7.widget.ActionMenuView; //導入依賴的package包/類
/**
 * It's important to set overflowDescription atribute in styles, so we can grab the reference
 * to the overflow icon. Check: res/values/styles.xml
 *
 * @param activity
 * @param colorFilter
 */
private static void setOverflowButtonColor(final Activity activity, final PorterDuffColorFilter colorFilter) {
    final String overflowDescription = activity.getString(R.string.abc_action_menu_overflow_description);
    final ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
    final ViewTreeObserver viewTreeObserver = decorView.getViewTreeObserver();
    viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            final ArrayList<View> outViews = new ArrayList<View>();
            decorView.findViewsWithText(outViews, overflowDescription,
                    View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION);
            if (outViews.isEmpty()) {
                return;
            }
            final ActionMenuView overflowViewParent = (ActionMenuView) outViews.get(0).getParent();
            overflowViewParent.getOverflowIcon().setColorFilter(colorFilter);
            removeOnGlobalLayoutListener(decorView, this);
        }
    });
}
 
開發者ID:h4h13,項目名稱:RetroMusicPlayer,代碼行數:27,代碼來源:ToolbarColorizeHelper.java

示例2: onGlobalLayout

import android.support.v7.widget.ActionMenuView; //導入依賴的package包/類
private void onGlobalLayout() {
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
        mToolbar.getViewTreeObserver().removeOnGlobalLayoutListener(mOnGlobalLayoutListener);
    else
        mToolbar.getViewTreeObserver().removeGlobalOnLayoutListener(mOnGlobalLayoutListener);

    ActionMenuView menuView = getMenuView();
    for(int i = 0, count = menuView == null ? 0 : menuView.getChildCount(); i < count; i++){
        View child = menuView.getChildAt(i);
        if(mRippleStyle != 0){
            if(child.getBackground() == null || !(child.getBackground() instanceof ToolbarRippleDrawable))
                ViewUtil.setBackground(child, getBackground());
        }
    }

    if(mGroupChanged){
        animateIn();
        mGroupChanged = false;
    }
}
 
開發者ID:XhinLiang,項目名稱:MDPreference,代碼行數:21,代碼來源:ToolbarManager.java

示例3: onCreateOptionsMenu

import android.support.v7.widget.ActionMenuView; //導入依賴的package包/類
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    ActionMenuView actionMenuView = ((ListHolderActivity) getActivity()).getActionMenuView();
    Menu actionMenu = actionMenuView.getMenu();
    actionMenu.clear();
    actionMenuView.setVisibility(View.GONE);
    inflater.inflate(R.menu.main, menu);
    MenuItem item = menu.add(1, 1001, 1, getString(R.string.grid_carousel));
    if (carousel) {
        item.setIcon(R.drawable.gridview);
    } else {
        item.setIcon(R.drawable.carousel);
    }

    MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
    actionMenuView.setOnMenuItemClickListener(new ActionMenuView.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem menuItem) {
            return onOptionsItemSelected(menuItem);
        }
    });
}
 
開發者ID:mrprona92,項目名稱:SecretBrand,代碼行數:23,代碼來源:HeroesList.java

示例4: showOverflowPrompt

import android.support.v7.widget.ActionMenuView; //導入依賴的package包/類
public void showOverflowPrompt(View view)
{
    final MaterialTapTargetPrompt.Builder tapTargetPromptBuilder = new MaterialTapTargetPrompt.Builder(this)
            .setPrimaryText(R.string.overflow_prompt_title)
            .setSecondaryText(R.string.overflow_prompt_description)
            .setAnimationInterpolator(new FastOutSlowInInterpolator())
            .setMaxTextWidth(R.dimen.tap_target_menu_max_width)
            .setIcon(R.drawable.ic_more_vert);
    final Toolbar tb = this.findViewById(android.support.v7.appcompat.R.id.action_bar);
    final View child = tb.getChildAt(2);
    if (child instanceof ActionMenuView)
    {
        final ActionMenuView actionMenuView = ((ActionMenuView) child);
        tapTargetPromptBuilder.setTarget(actionMenuView.getChildAt(actionMenuView.getChildCount() - 1));
    }
    else
    {
        Toast.makeText(this, R.string.overflow_unavailable, Toast.LENGTH_SHORT);
    }
    tapTargetPromptBuilder.show();
}
 
開發者ID:sjwall,項目名稱:MaterialTapTargetPrompt,代碼行數:22,代碼來源:EmptyActivity.java

示例5: showOverflowPrompt

import android.support.v7.widget.ActionMenuView; //導入依賴的package包/類
public void showOverflowPrompt(View view)
{
    final MaterialTapTargetPrompt.Builder tapTargetPromptBuilder = new MaterialTapTargetPrompt.Builder(this)
            .setPrimaryText(R.string.overflow_prompt_title)
            .setSecondaryText(R.string.overflow_prompt_description)
            .setAnimationInterpolator(new FastOutSlowInInterpolator())
            .setMaxTextWidth(R.dimen.tap_target_menu_max_width)
            .setIcon(R.drawable.ic_more_vert);
    final Toolbar tb = this.findViewById(R.id.toolbar);
    final View child = tb.getChildAt(2);
    if (child instanceof ActionMenuView)
    {
        final ActionMenuView actionMenuView = ((ActionMenuView) child);
        tapTargetPromptBuilder.setTarget(actionMenuView.getChildAt(actionMenuView.getChildCount() - 1));
    }
    else
    {
        Toast.makeText(this, R.string.overflow_unavailable, Toast.LENGTH_SHORT);
    }
    tapTargetPromptBuilder.show();
}
 
開發者ID:sjwall,項目名稱:MaterialTapTargetPrompt,代碼行數:22,代碼來源:MainActivity.java

示例6: showStylePrompt

import android.support.v7.widget.ActionMenuView; //導入依賴的package包/類
public void showStylePrompt(View view)
{
    final MaterialTapTargetPrompt.Builder builder = new MaterialTapTargetPrompt.Builder(this, R.style.MaterialTapTargetPromptTheme_FabTarget);
    final Toolbar tb = this.findViewById(R.id.toolbar);
    final View child = tb.getChildAt(2);
    if (child instanceof ActionMenuView)
    {
        final ActionMenuView actionMenuView = ((ActionMenuView) child);
        builder.setTarget(actionMenuView.getChildAt(actionMenuView.getChildCount() - 1));
    }
    else
    {
        Toast.makeText(this, R.string.overflow_unavailable, Toast.LENGTH_SHORT);
    }
    builder.setIcon(R.drawable.ic_more_vert)
            .show();
}
 
開發者ID:sjwall,項目名稱:MaterialTapTargetPrompt,代碼行數:18,代碼來源:MainActivity.java

示例7: showOverflowPrompt

import android.support.v7.widget.ActionMenuView; //導入依賴的package包/類
public void showOverflowPrompt(View view)
{
    final MaterialTapTargetPrompt.Builder tapTargetPromptBuilder = new MaterialTapTargetPrompt.Builder(this)
            .setPrimaryText(R.string.overflow_prompt_title)
            .setSecondaryText(R.string.overflow_prompt_description)
            .setAnimationInterpolator(new FastOutSlowInInterpolator())
            .setMaxTextWidth(R.dimen.max_prompt_width)
            .setIcon(R.drawable.ic_more_vert)
            .setClipToView(findViewById(R.id.dialog_view));
    final Toolbar tb = this.findViewById(R.id.toolbar);
    final View child = tb.getChildAt(2);
    if (child instanceof ActionMenuView)
    {
        final ActionMenuView actionMenuView = ((ActionMenuView) child);
        tapTargetPromptBuilder.setTarget(actionMenuView.getChildAt(actionMenuView.getChildCount() - 1));
    }
    else
    {
        Toast.makeText(this, R.string.overflow_unavailable, Toast.LENGTH_SHORT);
    }
    tapTargetPromptBuilder.show();
}
 
開發者ID:sjwall,項目名稱:MaterialTapTargetPrompt,代碼行數:23,代碼來源:DialogStyleActivity.java

示例8: findOverflowMenuButton

import android.support.v7.widget.ActionMenuView; //導入依賴的package包/類
private static ImageView findOverflowMenuButton(Activity activity, ViewGroup viewGroup) {
    if (viewGroup == null) {
        return null;
    }
    ImageView overflow = null;
    for (int i = 0, count = viewGroup.getChildCount(); i < count; i++) {
        View v = viewGroup.getChildAt(i);
        if (v instanceof ImageView
                && (v.getClass().getSimpleName().equals("OverflowMenuButton")
                || v instanceof ActionMenuView.ActionMenuChildView)) {
            overflow = (ImageView) v;
        } else if (v instanceof ViewGroup) {
            overflow = findOverflowMenuButton(activity, (ViewGroup) v);
        }
        if (overflow != null) {
            break;
        }
    }
    return overflow;
}
 
開發者ID:b1acKr0se,項目名稱:bridddle-for-dribbble,代碼行數:21,代碼來源:MenuTint.java

示例9: a

import android.support.v7.widget.ActionMenuView; //導入依賴的package包/類
public final View a(xp paramxp, View paramView, ViewGroup paramViewGroup)
{
  View localView = paramxp.getActionView();
  if ((localView == null) || (paramxp.f())) {
    localView = super.a(paramxp, paramView, paramViewGroup);
  }
  if (paramxp.isActionViewExpanded()) {}
  for (int i1 = 8;; i1 = 0)
  {
    localView.setVisibility(i1);
    ActionMenuView localActionMenuView = (ActionMenuView)paramViewGroup;
    ViewGroup.LayoutParams localLayoutParams = localView.getLayoutParams();
    if (!localActionMenuView.checkLayoutParams(localLayoutParams)) {
      localView.setLayoutParams(localActionMenuView.a(localLayoutParams));
    }
    return localView;
  }
}
 
開發者ID:ChiangC,項目名稱:FMTech,代碼行數:19,代碼來源:acl.java

示例10: onCreateView

import android.support.v7.widget.ActionMenuView; //導入依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
								 Bundle savedInstanceState) {
	// Inflate the layout for this fragment
	View v = inflater.inflate(R.layout.fragment_note, container, false);

	ButterKnife.bind(this, v);

	mEditTools.setTitle(null);

	getActivity().getMenuInflater().inflate(R.menu.menu_note_toolbar, mEditToolsMenu.getMenu());
	mEditToolsMenu.setOnMenuItemClickListener(new ActionMenuView.OnMenuItemClickListener() {
		@Override
		public boolean onMenuItemClick(MenuItem item) {
			return onOptionsItemSelected(item);
		}
	});

	return v;
}
 
開發者ID:nicktgn,項目名稱:TinyAndroidMVP,代碼行數:21,代碼來源:NoteFragment.java

示例11: draw

import android.support.v7.widget.ActionMenuView; //導入依賴的package包/類
@Override
public void draw(@NonNull View view, @NonNull Object value) {
    Toolbar toolbar = (Toolbar) view;
    int themeId = (int) value;
    try {
        ActionMenuView actionMenuView = (ActionMenuView) sActionMenuViewField.get(toolbar);
        if ( actionMenuView == null ){
            toolbar.getContext().setTheme(themeId);
        } else {
            MenuPresenter presenter = (MenuPresenter) sPresenterField.get(actionMenuView);
            Context context = (Context) sContextField.get(presenter);
            context.setTheme(themeId);
        }

    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
    toolbar.setPopupTheme((Integer) value);
}
 
開發者ID:ashqal,項目名稱:NightOwl,代碼行數:20,代碼來源:ToolbarHandler.java

示例12: onPrepareOptionsMenu

import android.support.v7.widget.ActionMenuView; //導入依賴的package包/類
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    //fixing toolbar icons after changing theme
    //should be fixed in next support release
    Toolbar t = (Toolbar) findViewById(R.id.toolbar);
    for (int i = 0; i < t.getChildCount(); i++) {
        if (t.getChildAt(i) instanceof ActionMenuView) {
            ActionMenuView v = (ActionMenuView) t.getChildAt(i);
            for (int j = 0; j < v.getChildCount(); j++) {
                if (v.getChildAt(j) instanceof TintImageView) {
                    TintImageView v1 = (TintImageView) v.getChildAt(j);
                    v1.setImageResource(R.drawable.abc_ic_menu_moreoverflow_mtrl_alpha);
                }
            }
        }
    }
    return super.onPrepareOptionsMenu(menu);
}
 
開發者ID:pbednarz,項目名稱:MaterialColors,代碼行數:19,代碼來源:MainActivity.java

示例13: onCreateOptionsMenu

import android.support.v7.widget.ActionMenuView; //導入依賴的package包/類
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    ActionMenuView actionMenuView = ((ListHolderActivity) getActivity()).getActionMenuView();
    Menu actionMenu = actionMenuView.getMenu();
    actionMenu.clear();
    actionMenuView.setVisibility(View.VISIBLE);
    inflater.inflate(R.menu.main, actionMenuView.getMenu());
    MenuItem item = actionMenu.add(1, 1001, 1, getString(R.string.grid_carousel));
    if (carousel) {
        item.setIcon(R.drawable.gridview);
    } else {
        item.setIcon(R.drawable.carousel);
    }
    MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
    actionMenuView.setOnMenuItemClickListener(new ActionMenuView.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem menuItem) {
            return onOptionsItemSelected(menuItem);
        }
    });
}
 
開發者ID:Histler,項目名稱:Infodota,代碼行數:22,代碼來源:HeroesList.java

示例14: getVisibleMenuItemList

import android.support.v7.widget.ActionMenuView; //導入依賴的package包/類
/**
 * Get the list of visible MenuItems
 *
 * @param toolbar
 * @return the list of visible MenuItems
 */
public static List<MenuItem> getVisibleMenuItemList(@NonNull Toolbar toolbar) {
    List<MenuItem> list = new ArrayList<>();
    for (int i = 0; i < toolbar.getChildCount(); i++) {
        final View v = toolbar.getChildAt(i);
        if (v instanceof ActionMenuView) {
            int childCount = ((ActionMenuView) v).getChildCount();
            for (int j = 0; j < childCount; j++) {
                final View innerView = ((ActionMenuView) v).getChildAt(j);
                if (innerView instanceof ActionMenuItemView) {
                    list.add(((ActionMenuItemView) innerView).getItemData());
                }
            }
        }
    }
    return list;
}
 
開發者ID:kaichunlin,項目名稱:android-transition,代碼行數:23,代碼來源:TransitionUtil.java

示例15: getMenuItem

import android.support.v7.widget.ActionMenuView; //導入依賴的package包/類
/**
 * Search for a particular menu
 *
 * @param toolbar
 * @param menuId
 * @return the corresponding MenuItem, or null if not found
 */
public static MenuItem getMenuItem(@NonNull Toolbar toolbar, @IdRes int menuId) {
    View v;
    int childCount;
    View innerView;
    MenuItem menuItem;
    for (int i = 0; i < toolbar.getChildCount(); i++) {
        v = toolbar.getChildAt(i);
        if (v instanceof ActionMenuView) {
            childCount = ((ActionMenuView) v).getChildCount();
            for (int j = 0; j < childCount; j++) {
                innerView = ((ActionMenuView) v).getChildAt(j);
                if (innerView instanceof ActionMenuItemView) {
                    menuItem = ((ActionMenuItemView) innerView).getItemData();
                    if (menuItem.getItemId() == menuId) {
                        return menuItem;
                    }
                }
            }
        }
    }
    return null;
}
 
開發者ID:kaichunlin,項目名稱:android-transition,代碼行數:30,代碼來源:TransitionUtil.java


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