How to get data from each dynamically created EditText in Android?

后端 未结 5 1086
盖世英雄少女心
盖世英雄少女心 2020-11-27 11:29

I have successfully created EditTexts depending on the user input in Android, and also I have assigned them unique ID\'s using setId() method.

Now wha

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-27 12:04

    this is because EditText.gettext() return Editable , so toString will not work . try String.valueOf(edittext.gettext) .

    if u sure that u r getting d right EditText but prob. is how 2 pass its test to string den code is

        EditText t = new EditText(this);
        t.setText("test");// obviously in ur case it will be intered by user
        String s = String.valueOf(t.getText());
        System.out.println(s);
    

    else use setTeg(Edittext) n get editText by getTag on button click .

提交回复
热议问题