Exception when focusing a EditText in a PopupWindow running on Device

后端 未结 7 2171
别那么骄傲
别那么骄傲 2021-02-12 22:38

I\'m developing a PopUp window for Android, and it\'s working, I added a EditText and a Button on that, when running on ADV this work properly, while running on device, when I f

7条回答
  •  没有蜡笔的小新
    2021-02-12 23:13

    Edited

    try like this create a new class say Popupcls

      public class PopUpFlag {
            private PopupWindow pw;
    
        public void initiatePopupWindow(Activity ctx) {
         LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    
        View layout = inflater.inflate(R.layout.popupprofile,  (ViewGroup) ctx.findViewById(R.id.popup_element));
        EditText ettext = (EditText) layout.findViewById(R.id.edit);
        pw = new PopupWindow(layout, 300, 400, true);
        pw.showAtLocation(layout, Gravity.BOTTOM, 0, 0);
        }
    

    Now in your activity if you need popup when popup button click write like this

    popupbtn.setOnClickListener(new OnClickListener() {
    
                @Override
                public void onClick(View v) {
    
                    PopUpFlag puf=new PopUpFlag();
                    puf.initiatePopupWindow(YourActivityName.this);
                }
            });
    

    I hope this helps

提交回复
热议问题