Users Pricing

forum

Home Forums How to show Popup Window in Android. I am using below code but it give fatal exception. – MindStick

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

Anonymous User 2290 14 Jun 2016
  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);

2 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md