Android popupWindow, cant get elements within popup

前端 未结 3 1833
长发绾君心
长发绾君心 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 01:51

    try to impliment popupwindow like this.

    0 讨论(0)
  • 2021-01-19 02:04

    use this layout.findViewById(R.id.popup_element)); instead of this findViewById(R.id.popup_element));

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题