Popupwindows抛出错误,但项目工作正常

时间:2014-06-26 09:35:53

标签: android popupwindow

这是我的PopupwindowActivity。当我运行这个程序时。它没有显示任何错误,但是在点击Button时它会在log cat中抛出一些错误。但它仍然是工作正常。任何人都告诉我如何处理这些错误

    import android.app.Activity;
    import android.os.Bundle;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.view.ViewGroup.LayoutParams;
    import android.widget.Button;
    import android.widget.PopupWindow;

    public class AndroidPopupWindowActivity extends Activity {
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);

            final Button btnOpenPopup = (Button)findViewById(R.id.openpopup);
            btnOpenPopup.setOnClickListener(new Button.OnClickListener(){

       @Override
       public void onClick(View arg0) {
        LayoutInflater layoutInflater  = (LayoutInflater)getBaseContext()
          .getSystemService(LAYOUT_INFLATER_SERVICE);  
        View popupView = layoutInflater.inflate(R.layout.popup, null);  
                 final PopupWindow popupWindow = new PopupWindow(
                   popupView, 
                   LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);  
                   Button btnDismiss = (Button)popupView.findViewById(R.id.dismiss);
                   btnDismiss.setOnClickListener(new Button.OnClickListener(){

         @Override
         public void onClick(View v) {
          // TODO Auto-generated method stub
          popupWindow.dismiss();
         }});

                 popupWindow.showAsDropDown(btnOpenPopup, 50, -30);

       }});
        }
    }

logcat的

06-26 14:56:51.514: E/WindowManager(9581): Activity com.example.popupwindows.AndroidPopupWindowActivity has leaked window android.widget.LinearLayout{4257c0e0 V.E..... ......I. 0,0-222,233} that was originally added here
06-26 14:56:51.514: E/WindowManager(9581): android.view.WindowLeaked: Activity com.example.popupwindows.AndroidPopupWindowActivity has leaked window android.widget.LinearLayout{4257c0e0 V.E..... ......I. 0,0-222,233} that was originally added here
06-26 14:56:51.514: E/WindowManager(9581):  at android.view.ViewRootImpl.<init>(ViewRootImpl.java:457)
06-26 14:56:51.514: E/WindowManager(9581):  at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:235)
06-26 14:56:51.514: E/WindowManager(9581):  at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:73)
06-26 14:56:51.514: E/WindowManager(9581):  at android.widget.PopupWindow.invokePopup(PopupWindow.java:1044)
06-26 14:56:51.514: E/WindowManager(9581):  at android.widget.PopupWindow.showAsDropDown(PopupWindow.java:950)
06-26 14:56:51.514: E/WindowManager(9581):  at com.example.popupwindows.AndroidPopupWindowActivity$1.onClick(AndroidPopupWindowActivity.java:37)
06-26 14:56:51.514: E/WindowManager(9581):  at android.view.View.performClick(View.java:4432)
06-26 14:56:51.514: E/WindowManager(9581):  at android.view.View$PerformClick.run(View.java:18339)
06-26 14:56:51.514: E/WindowManager(9581):  at android.os.Handler.handleCallback(Handler.java:725)
06-26 14:56:51.514: E/WindowManager(9581):  at android.os.Handler.dispatchMessage(Handler.java:92)
06-26 14:56:51.514: E/WindowManager(9581):  at android.os.Looper.loop(Looper.java:137)
06-26 14:56:51.514: E/WindowManager(9581):  at android.app.ActivityThread.main(ActivityThread.java:5283)
06-26 14:56:51.514: E/WindowManager(9581):  at java.lang.reflect.Method.invokeNative(Native Method)
06-26 14:56:51.514: E/WindowManager(9581):  at java.lang.reflect.Method.invoke(Method.java:511)
06-26 14:56:51.514: E/WindowManager(9581):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
06-26 14:56:51.514: E/WindowManager(9581):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
06-26 14:56:51.514: E/WindowManager(9581):  at dalvik.system.NativeStart.main(Native Method)
06-26 14:56:51.524: E/InputEventReceiver(9581): channel ~ Publisher closed input channel or an error occurred.  events=0x9

0 个答案:

没有答案