在列表弹出菜单项选择中执行gridview中的操作

时间:2014-01-09 15:34:40

标签: android adapter popupwindow

我想在列表弹出菜单中添加操作,例如with Play Store App in this POST

我取得了很好的成绩,但我面临着一个严重的问题。

点击动作后,我想在GridView项目中执行一些操作。

enter image description here

我尝试在我的适配器中执行此操作,方法是将position方法的getView参数传递给我的onListItemClickListner。但我注意到网格初始化后position的值保持不变。

public View getView(int gridPosition, View convertView, ViewGroup parent) {
        View rowView = convertView;
        // some code

            mAdapter = new PopupMenuAdapter(context, popupData);
            popupWindow = new IcsListPopupWindow(
                    context);
            popupWindow.setBackgroundDrawable(context.getResources()
                    .getDrawable(R.drawable.list_popup_shadow));
            popupWindow.setAdapter(mAdapter);
            popupWindow.setModal(true);

            popupWindow.setOnItemClickListener(new PopupListItemListner(id));
            // upon clicking on a button, show the popup menu :
            holder.shortcut.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(final View v) {
                    // show popup menu:
                    popupWindow.setContentWidth(activity.getWindowManager()
                            .getDefaultDisplay().getWidth() / 3);
                    popupWindow.setAnchorView(v);
                    popupWindow.show();
                }
            });

        // ...

        return rowView;
    }

我不知道我该怎么做。

0 个答案:

没有答案