HOW TO SHOW POPUP WINDOW IN ANDROID. I AM USING BELOW CODE BUT IT GIVE FATAL EXCEPTION.

Linda Perla

Total Post:13

Points:93
Posted by  Linda Perla
 458  View(s)
Ratings:
Rate this:
  PopupWindow popupWindow = new PopupWindow(getApplicationContext());
        
        // inflate your layout or dynamically add view
        LayoutInflater inflater = (LayoutInflater) getWindow().getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.my_layout, null);
        popupWindow.setFocusable(true);
        popupWindow.setWidth(WindowManager.LayoutParams.WRAP_CONTENT);
        popupWindow.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
        popupWindow.setContentView(view);      
        popupWindow.showAsDropDown(v);
  1. Manoj Pandey

    Post:26

    Points:188
    Re: How to show Popup Window in Android. I am using below code but it give fatal exception.

     Hi Linda

     Use below code
     PopupWindow popupWindow = new PopupWindow(getWindow().getContext());

    instead of
     PopupWindow popupWindow = new PopupWindow(getApplicationContext());

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!