我有 3 个选项卡,每个选项卡都有一个列表视图。我已经为上下文菜单注册了这些列表视图。我有三个不同的数组列表,我在其中存储各个列表视图的项目。
现在我想要被点击的列表视图项目的位置。
我的代码是:
public boolean onContextItemSelected(MenuItem item) {
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
switch(item.getItemId()){
case R.id.mycards_contextmenu_1:
if(mCurrentTab.equals("Tab 1")){
try{
int pos= info.position;
Toast.makeText(getBaseContext(), pos, Toast.LENGTH_LONG).show();
}catch(Exception e){
Toast.makeText(getBaseContext(), e.toString(), Toast.LENGTH_LONG).show();
}
}
break;
}
我正进入(状态
android.content.res.resources$notfoundexception
我哪里出错了?
编辑:
Stack Trace :
03-14 22:06:12.488: E/AndroidRuntime(3055): FATAL EXCEPTION: main
03-14 22:06:12.488: E/AndroidRuntime(3055): android.content.res.Resources$NotFoundException: String resource ID #0x0
03-14 22:06:12.488: E/AndroidRuntime(3055): at android.content.res.Resources.getText(Resources.java:229)
03-14 22:06:12.488: E/AndroidRuntime(3055): at android.widget.Toast.makeText(Toast.java:265)
03-14 22:06:12.488: E/AndroidRuntime(3055): at neeraj.cardXchange.myCardsPackage.myCardsActivity.onContextItemSelected(myCardsActivity.java:211)
03-14 22:06:12.488: E/AndroidRuntime(3055): at android.app.Activity.onMenuItemSelected(Activity.java:2552)
03-14 22:06:12.488: E/AndroidRuntime(3055): at com.android.internal.policy.impl.PhoneWindow$DialogMenuCallback.onMenuItemSelected(PhoneWindow.java:3601)
03-14 22:06:12.488: E/AndroidRuntime(3055): at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:735)
03-14 22:06:12.488: E/AndroidRuntime(3055): at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:149)
03-14 22:06:12.488: E/AndroidRuntime(3055): at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:874)
03-14 22:06:12.488: E/AndroidRuntime(3055): at com.android.internal.view.menu.MenuDialogHelper.onClick(MenuDialogHelper.java:167)
03-14 22:06:12.488: E/AndroidRuntime(3055): at com.android.internal.app.AlertController$AlertParams$3.onItemClick(AlertController.java:924)
03-14 22:06:12.488: E/AndroidRuntime(3055): at android.widget.AdapterView.performItemClick(AdapterView.java:298)
03-14 22:06:12.488: E/AndroidRuntime(3055): at android.widget.AbsListView.performItemClick(AbsListView.java:1086)
03-14 22:06:12.488: E/AndroidRuntime(3055): at android.widget.AbsListView$PerformClick.run(AbsListView.java:2855)
03-14 22:06:12.488: E/AndroidRuntime(3055): at android.widget.AbsListView$1.run(AbsListView.java:3529)
03-14 22:06:12.488: E/AndroidRuntime(3055): at android.os.Handler.handleCallback(Handler.java:615)
03-14 22:06:12.488: E/AndroidRuntime(3055): at android.os.Handler.dispatchMessage(Handler.java:92)
03-14 22:06:12.488: E/AndroidRuntime(3055): at android.os.Looper.loop(Looper.java:137)
03-14 22:06:12.488: E/AndroidRuntime(3055): at android.app.ActivityThread.main(ActivityThread.java:4745)
03-14 22:06:12.488: E/AndroidRuntime(3055): at java.lang.reflect.Method.invokeNative(Native Method)
03-14 22:06:12.488: E/AndroidRuntime(3055): at java.lang.reflect.Method.invoke(Method.java:511)
03-14 22:06:12.488: E/AndroidRuntime(3055): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
03-14 22:06:12.488: E/AndroidRuntime(3055): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
03-14 22:06:12.488: E/AndroidRuntime(3055): at dalvik.system.NativeStart.main(Native Method)