当前位置: 首页>>代码示例>>Java>>正文


Java ActionMenuItem类代码示例

本文整理汇总了Java中android.support.v7.view.menu.ActionMenuItem的典型用法代码示例。如果您正苦于以下问题:Java ActionMenuItem类的具体用法?Java ActionMenuItem怎么用?Java ActionMenuItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ActionMenuItem类属于android.support.v7.view.menu包,在下文中一共展示了ActionMenuItem类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onBindViewHolder

import android.support.v7.view.menu.ActionMenuItem; //导入依赖的package包/类
@Override
    public void onBindViewHolder(final ViewHolder holder, int position) {
        final ActionMenuItem actionMenuItem = menuItems.get(position);
        holder.icon.setImageDrawable(actionMenuItem.getIcon());
        holder.text.setText(actionMenuItem.getTitle());
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (clickListener != null) {
                    clickListener.onClick(view, actionMenuItem);
                }
            }
        });
//        int location = position % 3;
//        if ( location == 0){
//            // left
//            holder.llContainer.setLayoutParams(getFrameLayoutParams(true));
//            return;
//        }
//        if (location == 1){
//            // center
//            holder.llContainer.setLayoutParams(getFrameLayoutParams(null));
//            return;
//        }
//        if (location == 2){
//            // right
//            holder.llContainer.setLayoutParams(getFrameLayoutParams(false));
//            return;
//        }
    }
 
开发者ID:didikee,项目名称:CommonDependence,代码行数:31,代码来源:ShareGridAdapter.java

示例2: setClickListener

import android.support.v7.view.menu.ActionMenuItem; //导入依赖的package包/类
public void setClickListener(OnSampleClickListener<ActionMenuItem> clickListener) {
    this.clickListener = clickListener;
}
 
开发者ID:didikee,项目名称:CommonDependence,代码行数:4,代码来源:ShareGridAdapter.java

示例3: setMenuItems

import android.support.v7.view.menu.ActionMenuItem; //导入依赖的package包/类
public void setMenuItems(List<ActionMenuItem> menuItems) {
    this.menuItems = menuItems;
}
 
开发者ID:didikee,项目名称:CommonDependence,代码行数:4,代码来源:ShareGridAdapter.java

示例4: handleShareWithBottomSheets

import android.support.v7.view.menu.ActionMenuItem; //导入依赖的package包/类
private void handleShareWithBottomSheets(@NonNull final Activity activity, @NonNull
        BottomSheetDialog
        shareDialog, @NonNull final Intent shareIntent) {
    List<ActionMenuItem> menus = new ArrayList<>();
    shareDialog.setCanceledOnTouchOutside(false);
    RecyclerView gridView = ((RecyclerView) shareDialog.findViewById(R.id.recyclerView));
    if (gridView == null) {
        throw new NullPointerException("you should declare a id named recyclerView in your " +
                "bottomSheets layout!");
    }
    int grid = 4;
    gridView.setLayoutManager(new GridLayoutManager(activity, grid));
    gridView.setNestedScrollingEnabled(false);
    gridView.setFocusable(false);
    gridView.setHasFixedSize(true);
    int v = DisplayUtil.dp2px(activity, 3);
    int h = DisplayUtil.dp2px(activity, 8);
    SpaceGridItemDecoration spaceItemDecoration = new SpaceGridItemDecoration(grid, h, v,
            h, v);
    ShareGridAdapter gridAdapter = new ShareGridAdapter();
    gridView.setAdapter(gridAdapter);
    gridView.addItemDecoration(spaceItemDecoration);


    PackageManager pm = activity.getPackageManager();
    final List<ResolveInfo> list = pm.queryIntentActivities(shareIntent, 0);
    for (int i = 0; i < list.size(); i++) {
        ActionMenuItem item = new ActionMenuItem(activity, 0, i, 0, 0, list.get(i).loadLabel
                (pm));
        item.setIcon(list.get(i).loadIcon(pm));
        menus.add(item);
    }

    gridAdapter.setClickListener(new OnSampleClickListener<ActionMenuItem>() {
        @Override
        public void onClick(View view, ActionMenuItem obj) {
            ActivityInfo activityInfo = list.get(obj.getItemId()).activityInfo;
            ComponentName name = new ComponentName(activityInfo.applicationInfo.packageName,
                    activityInfo.name);
            shareIntent.setComponent(name);
            activity.startActivity(shareIntent);
        }
    });
    gridAdapter.setMenuItems(menus);
    gridAdapter.notifyDataSetChanged();
    shareDialog.show();
}
 
开发者ID:didikee,项目名称:CommonDependence,代码行数:48,代码来源:AndroidShareHelper.java

示例5: ToolbarWidgetWrapper

import android.support.v7.view.menu.ActionMenuItem; //导入依赖的package包/类
public ToolbarWidgetWrapper(Toolbar toolbar, boolean style, int defaultNavigationContentDescription, int defaultNavigationIcon) {
    this.mNavigationMode = 0;
    this.mDefaultNavigationContentDescription = 0;
    this.mToolbar = toolbar;
    this.mTitle = toolbar.getTitle();
    this.mSubtitle = toolbar.getSubtitle();
    this.mTitleSet = this.mTitle != null;
    this.mNavIcon = toolbar.getNavigationIcon();
    if (style) {
        TintTypedArray a = TintTypedArray.obtainStyledAttributes(toolbar.getContext(), null, R.styleable.ActionBar, R.attr.actionBarStyle, 0);
        CharSequence title = a.getText(R.styleable.ActionBar_title);
        if (!TextUtils.isEmpty(title)) {
            setTitle(title);
        }
        CharSequence subtitle = a.getText(R.styleable.ActionBar_subtitle);
        if (!TextUtils.isEmpty(subtitle)) {
            setSubtitle(subtitle);
        }
        Drawable logo = a.getDrawable(R.styleable.ActionBar_logo);
        if (logo != null) {
            setLogo(logo);
        }
        Drawable icon = a.getDrawable(R.styleable.ActionBar_icon);
        if (this.mNavIcon == null && icon != null) {
            setIcon(icon);
        }
        Drawable navIcon = a.getDrawable(R.styleable.ActionBar_homeAsUpIndicator);
        if (navIcon != null) {
            setNavigationIcon(navIcon);
        }
        setDisplayOptions(a.getInt(R.styleable.ActionBar_displayOptions, 0));
        int customNavId = a.getResourceId(R.styleable.ActionBar_customNavigationLayout, 0);
        if (customNavId != 0) {
            setCustomView(LayoutInflater.from(this.mToolbar.getContext()).inflate(customNavId, this.mToolbar, false));
            setDisplayOptions(this.mDisplayOpts | 16);
        }
        int height = a.getLayoutDimension(R.styleable.ActionBar_height, 0);
        if (height > 0) {
            LayoutParams lp = this.mToolbar.getLayoutParams();
            lp.height = height;
            this.mToolbar.setLayoutParams(lp);
        }
        int contentInsetStart = a.getDimensionPixelOffset(R.styleable.ActionBar_contentInsetStart, -1);
        int contentInsetEnd = a.getDimensionPixelOffset(R.styleable.ActionBar_contentInsetEnd, -1);
        if (contentInsetStart >= 0 || contentInsetEnd >= 0) {
            this.mToolbar.setContentInsetsRelative(Math.max(contentInsetStart, 0), Math.max(contentInsetEnd, 0));
        }
        int titleTextStyle = a.getResourceId(R.styleable.ActionBar_titleTextStyle, 0);
        if (titleTextStyle != 0) {
            this.mToolbar.setTitleTextAppearance(this.mToolbar.getContext(), titleTextStyle);
        }
        int subtitleTextStyle = a.getResourceId(R.styleable.ActionBar_subtitleTextStyle, 0);
        if (subtitleTextStyle != 0) {
            this.mToolbar.setSubtitleTextAppearance(this.mToolbar.getContext(), subtitleTextStyle);
        }
        int popupTheme = a.getResourceId(R.styleable.ActionBar_popupTheme, 0);
        if (popupTheme != 0) {
            this.mToolbar.setPopupTheme(popupTheme);
        }
        a.recycle();
    } else {
        this.mDisplayOpts = detectDisplayOptions();
    }
    this.mDrawableManager = AppCompatDrawableManager.get();
    setDefaultNavigationContentDescription(defaultNavigationContentDescription);
    this.mHomeDescription = this.mToolbar.getNavigationContentDescription();
    setDefaultNavigationIcon(this.mDrawableManager.getDrawable(getContext(), defaultNavigationIcon));
    this.mToolbar.setNavigationOnClickListener(new OnClickListener() {
        final ActionMenuItem mNavItem = new ActionMenuItem(ToolbarWidgetWrapper.this.mToolbar.getContext(), 0, 16908332, 0, 0, ToolbarWidgetWrapper.this.mTitle);

        public void onClick(View v) {
            if (ToolbarWidgetWrapper.this.mWindowCallback != null && ToolbarWidgetWrapper.this.mMenuPrepared) {
                ToolbarWidgetWrapper.this.mWindowCallback.onMenuItemSelected(0, this.mNavItem);
            }
        }
    });
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:78,代码来源:ToolbarWidgetWrapper.java


注:本文中的android.support.v7.view.menu.ActionMenuItem类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。