Skip to content Skip to sidebar Skip to footer

How To Get Values From Dynamically Created Edittext Fields?

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 should get the values from the

Solution 1:

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 ;)

Solution 2:

btn_no_of.setOnClickListener(newView.OnClickListener() {

        @OverridepublicvoidonClick(View v) {
            // TODO Auto-generated method stubString str1=edittext1.gettext.tostring();
                            String str2=edittext2.gettext.tostring();

        }
    });

Post a Comment for "How To Get Values From Dynamically Created Edittext Fields?"