0
我正在做一個音樂文件的各種類型的操作的上下文菜單。但我無法獲得上下文菜單項選擇。在下面的代碼test4contextmenu
是一個包含TextView
佈局的類。ContextMenu項目選擇?
public boolean onContextItemSelected(MenuItem item) {
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo)item.getMenuInfo();
int menuItemIndex = item.getItemId();
String menuItemName = menuItems[menuItemIndex];
String songName = songs.get(info.position);
text = (TextView)findViewById(R.id.text1);
text.setText(String.format("Selected %s for item %s", menuItemName, songName));
startActivity(new Intent(this,test4contextmenu.class));
return true;
}