1
看看下面的代碼...爲什麼我的上下文菜單正在創建?這可能是什麼原因...?上下文菜單不出現
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
MenuInflater inflator = getMenuInflater();
inflator.inflate(R.menu.contextmenudisplayer, menu);
}
@Override
public boolean onContextItemSelected(MenuItem item) {
switch(item.getItemId())
{
case R.id.delete:
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
String s = (String) ((Cursor) getListView().getItemAtPosition(info.position))
.getString(2);
Log.v("ID is", s);
default:
return super.onContextItemSelected(item);
}
}
,這裏是xml文件,從上下文菜單中顯示器的代碼 contextmenudisplayer.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/delete"
android:title="Delete Message">
</item>
<item
android:id="@+id/forward"
android:title="Forward">
</item>
</menu>