Android popupWindow, cant get elements within popup

前端 未结 3 1832
长发绾君心
长发绾君心 2021-01-19 01:34

I am having an issue with grabbing my Buttons and other elements from within my PopupWindow, using the debugger it just report back as

3条回答
  •  星月不相逢
    2021-01-19 02:13

    You can get like

    View layout = inflater.inflate(R.layout.activity_register,
                (ViewGroup) youractivity.this.findViewById(R.id.popup_element));
    
    btnReg = (Button) layout.findViewById(R.id.btnReg);
    inputName = (EditText) layout.findViewById(R.id.name);
    inputDOB = (DatePicker) layout.findViewById(R.id.dob);
    

    It's becoz your all the elements coming from inflated layout view and you need to pass context to get your popup_element layout as ViewGroup.

提交回复
热议问题