ContextMenu
为每个 ImageView注册可能会起作用。像这样:
@Override
public View getView(int arg0, View arg1, ViewGroup arg2) {
if (arg1 == null) {
LayoutInflater vi = (LayoutInflater) cmx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
arg1 = vi.inflate(R.layout.services_item, null);
}
ImageView serviceThumb = (ImageView) arg1.findViewById(R.id.thumbIView);
registerForContextMenu(serviceThumb);
serviceThumb.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
@Override
public void onCreateContextMenu(ContextMenu menu, View v,ContextMenuInfo menuInfo) {
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo)menuInfo;
menu.setHeaderTitle("Test");
for (int i = 0; i< 5; i++) {
menu.add(Menu.NONE, i, i, i + " - Test");
}
}
});
}