0
我想要實現的PopupMenu像谷歌打下面的應用程序是我的代碼實現PopupMenu的使用android.support.v7.appcompat
PopupMenu popup = new PopupMenu(MainActivity.this, v);
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem arg0) {
// TODO Auto-generated method stub
return false;
}
});
popup.inflate(R.menu.menu_popup);
popup.show();
我已經加入appcompat7我的應用程序lib文件夾。下面是崩潰報告,當我在點擊鏈接
01-23 12:05:59.690: E/AndroidRuntime(14728): FATAL EXCEPTION: main
01-23 12:05:59.690: E/AndroidRuntime(14728): java.lang.IllegalStateException: Could not execute method of the activity
01-23 12:05:59.690: E/AndroidRuntime(14728): at android.view.View$1.onClick(View.java:3607)
01-23 12:05:59.690: E/AndroidRuntime(14728): at android.view.View.performClick(View.java:4212)
01-23 12:05:59.690: E/AndroidRuntime(14728): at android.view.View$PerformClick.run(View.java:17477)
01-23 12:05:59.690: E/AndroidRuntime(14728): at android.os.Handler.handleCallback(Handler.java:800)
01-23 12:05:59.690: E/AndroidRuntime(14728): at android.os.Handler.dispatchMessage(Handler.java:100)
01-23 12:05:59.690: E/AndroidRuntime(14728): at android.os.Looper.loop(Looper.java:194)
01-23 12:05:59.690: E/AndroidRuntime(14728): at android.app.ActivityThread.main(ActivityThread.java:5371)
01-23 12:05:59.690: E/AndroidRuntime(14728): at java.lang.reflect.Method.invokeNative(Native Method)
01-23 12:05:59.690: E/AndroidRuntime(14728): at java.lang.reflect.Method.invoke(Method.java:525)
01-23 12:05:59.690: E/AndroidRuntime(14728): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
01-23 12:05:59.690: E/AndroidRuntime(14728): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
01-23 12:05:59.690: E/AndroidRuntime(14728): at dalvik.system.NativeStart.main(Native Method)
01-23 12:05:59.690: E/AndroidRuntime(14728): Caused by: java.lang.reflect.InvocationTargetException
01-23 12:05:59.690: E/AndroidRuntime(14728): at java.lang.reflect.Method.invokeNative(Native Method)
01-23 12:05:59.690: E/AndroidRuntime(14728): at java.lang.reflect.Method.invoke(Method.java:525)
01-23 12:05:59.690: E/AndroidRuntime(14728): at android.view.View$1.onClick(View.java:3602)
01-23 12:05:59.690: E/AndroidRuntime(14728): ... 11 more
01-23 12:05:59.690: E/AndroidRuntime(14728): Caused by: java.lang.NoClassDefFoundError: android.support.v7.appcompat.R$layout
01-23 12:05:59.690: E/AndroidRuntime(14728): at android.support.v7.internal.view.menu.MenuPopupHelper.<clinit>(MenuPopupHelper.java:50)
01-23 12:05:59.690: E/AndroidRuntime(14728): at android.support.v7.widget.PopupMenu.<init>(PopupMenu.java:69)
01-23 12:05:59.690: E/AndroidRuntime(14728): at com.vs2.popupmenuexample.MainActivity.showPopup(MainActivity.java:26)
01-23 12:05:59.690: E/AndroidRuntime(14728): ... 14 more