forum

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

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

Anonymous User 1855 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);

Updated on 27-Jun-2023
I am a content writter !

Can you answer this question?


Answer

2 Answers

Liked By