こんにちは、私のアプリケーションでは、expandableListView を使用しています。展開可能な listView の contextMenu を統合する必要があります。私の拡張可能な ListView では、さまざまな子のさまざまなレイアウトを膨らませます。そのため、各 childView を長押しすると、別のアクションを実行する必要があります。
ここで、ContextMenu のコードを示します。
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
ExpandableListView.ExpandableListContextMenuInfo info=
(ExpandableListView.ExpandableListContextMenuInfo)menuInfo;
int type=ExpandableListView.getPackedPositionType(info.packedPosition);
Log.e("type",""+type);
menu.setHeaderTitle("Options");
menu.add(1, 1, 1, "Edit");
}
@Override
public boolean onContextItemSelected(MenuItem item) {
ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo)item.getMenuInfo();
if(item.getItemId()==1)
{
Log.e("clickd","menu");
}
return super.onContextItemSelected(item);
}
私の onCreate() で、ListView forContextMenu を登録します。
registerForContextMenu(expListView);
しかし、GroupView を押すと、contextMenu が表示されます。しかし、childViewをクリックすると、ContextMenuが表示されません..助けてください.....