Android can't get EditText getText().toString() in a Dialog

后端 未结 1 643
深忆病人
深忆病人 2021-01-14 04:15

I\'m trying to create a custom Dialog in an individual class. The dialog is started in the main activity:

        DialogLogin login = new DialogLogin();
            


        
相关标签:
1条回答
  • 2021-01-14 04:56

    You are inflating a new layout, where the EditText has no text in it. You'll need to only once inflate your layout, and keep a reference to it.

    final View view = inflater.inflate(R.layout.loginlayout, null);
    
    /* ... */
    .setView(view)
    /* ... */
    EditText text = (EditText) view.findViewById(R.id.loginEdit);
    
    0 讨论(0)
提交回复
热议问题