我在以下代码片段中遇到一个错误。我尝试调试它但没有用。
代码片段 -
public void createNewList(){
popupCreateList = new PopupWindow(popupCreateListView,LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
popupCreateList.setBackgroundDrawable(new BitmapDrawable());
popupCreateList.setOutsideTouchable(true);
((LinearLayout)popUpListView.getParent()).removeView(popUpListView);
Log.i(TAG,"popupCreateList-->>>" + popupCreateList + R.layout.layout_task_manager);
EXCEPTION--> popupCreateList.showAtLocation(findViewById(R.layout.layout_task_manager), Gravity.CENTER, 0, 0);
//popupCreateList.showAsDropDown(listsButton, 50, -30);
}
日志猫 -
12-29 04:20:44.041: E/AndroidRuntime(885): FATAL EXCEPTION: main
12-29 04:20:44.041: E/AndroidRuntime(885): java.lang.NullPointerException
12-29 04:20:44.041: E/AndroidRuntime(885): at android.widget.PopupWindow.showAtLocation(PopupWindow.java:809)
12-29 04:20:44.041: E/AndroidRuntime(885): at ray.kaushik.simple.task.manager.TaskManagerActivity.createNewList(TaskManagerActivity.java:338)
12-29 04:20:44.041: E/AndroidRuntime(885): at ray.kaushik.simple.task.manager.TaskManagerActivity.onMenuItemSelected(TaskManagerActivity.java:323)
12-29 04:20:44.041: E/AndroidRuntime(885): at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:958)
12-29 04:20:44.041: E/AndroidRuntime(885): at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:735)
12-29 04:20:44.041: E/AndroidRuntime(885): at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:149)
12-29 04:20:44.041: E/AndroidRuntime(885): at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:874)
12-29 04:20:44.041: E/AndroidRuntime(885): at com.android.internal.view.menu.IconMenuView.invokeItem(IconMenuView.java:468)
12-29 04:20:44.041: E/AndroidRuntime(885): at com.android.internal.view.menu.IconMenuItemView.performClick(IconMenuItemView.java:126)
12-29 04:20:44.041: E/AndroidRuntime(885): at android.view.View$PerformClick.run(View.java:16966)
12-29 04:20:44.041: E/AndroidRuntime(885): at android.os.Handler.handleCallback(Handler.java:615)
12-29 04:20:44.041: E/AndroidRuntime(885): at android.os.Handler.dispatchMessage(Handler.java:92)
12-29 04:20:44.041: E/AndroidRuntime(885): at android.os.Looper.loop(Looper.java:137)
12-29 04:20:44.041: E/AndroidRuntime(885): at android.app.ActivityThread.main(ActivityThread.java:4745)
12-29 04:20:44.041: E/AndroidRuntime(885): at java.lang.reflect.Method.invokeNative(Native Method)
12-29 04:20:44.041: E/AndroidRuntime(885): at java.lang.reflect.Method.invoke(Method.java:511)
12-29 04:20:44.041: E/AndroidRuntime(885): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
12-29 04:20:44.041: E/AndroidRuntime(885): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
12-29 04:20:44.041: E/AndroidRuntime(885): at dalvik.system.NativeStart.main(Native Method)
编辑 - 1
我正在尝试显示弹出窗口的 findViewById(R.layout.layout_task_manager) 获得 NULL 值。