我想在列表弹出菜单中添加操作,例如with Play Store App in this POST。
我取得了很好的成绩,但我面临着一个严重的问题。
点击动作后,我想在GridView
项目中执行一些操作。
我尝试在我的适配器中执行此操作,方法是将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;
}
我不知道我该怎么做。