How to get values from dynamically created EditText fields?

后端 未结 2 832
半阙折子戏
半阙折子戏 2021-01-07 11:07

I am little confused with following scenario:

I have an add button which I use it to add a number of EditText fields, when I tap on the save button I sh

相关标签:
2条回答
  • 2021-01-07 11:51

    You could do something like this:

    Store all the EditText fields you create programmatically inside a List. So whenever you have viewGroup.add(myEditText); you would also have myList.add(myEditText);

    Then when you press 'save' just loop on your list and use getText() to get the data from your EditText fields.

    I'm sure there are also other ways to accomplish this ;)

    0 讨论(0)
  • 2021-01-07 12:02
    btn_no_of.setOnClickListener(new View.OnClickListener() {
    
            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
    
                String str1=edittext1.gettext.tostring();
                                String str2=edittext2.gettext.tostring();
    
            }
        });
    
    0 讨论(0)
提交回复
热议问题