1.mTestArray =  = getResources().getStringArray(R.array.testArray);

2.右键菜单和主菜单有些区别

switch(item.getItemId())  
  {  
  case 0:  
    ShowAlert("hello from delete item"); 
    break;  
  default:  
  return super.onContextItemSelected(item);  
  }  
  return true;

这样子就好

private static final int EDIT_ID = Menu.FIRST + 3; 
private static final int DELETE_ID = Menu.FIRST + 4; 
 @Override 
    public void onCreateContextMenu(ContextMenu menu, View v, 
            ContextMenu.ContextMenuInfo menuInfo) { 
        menu.add(Menu.NONE, EDIT_ID, Menu.NONE, "Edit").setAlphabeticShortcut( 
                'e'); 
        menu.add(Menu.NONE, DELETE_ID, Menu.NONE, "Delete") 
                .setAlphabeticShortcut('d'); 
    } 
 
    @Override 
    public boolean onContextItemSelected(MenuItem item) { 
        AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item .getMenuInfo(); 
        switch (item.getItemId()) { 
        case EDIT_ID: 
 
            edit(info.id); 
            return (true); 
        case DELETE_ID: 
 
            delete(info.id); 
            return (true); 
        } 
 
        return (super.onOptionsItemSelected(item)); 
    }

 

或者

@Override 
public boolean onContextItemSelected(MenuItem item) { 
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); 
    int index = info.position; 
    View view = info.targetView; 
}