Android Listview Edittext With TextView Get/Set Text Values Of EditText

Android Listview Edittext With TextView Tutorial Example is today’s topic.

We will implement Custom Listview with EditText and will set and get text values of all edittext in all child elements of listview.

Many developers have oftern several problems regarding this topic like:

  1. Value of edittext changes when scrolling
  2. How to set edittext value in listview items
  3. How to retain edittext value while scrolling
  4. How to get all the text values of all the edittexts of listview and pass it to next activity.

Today’s tutorial will give perfect answers and solutions of above problems.

TextWatcher class is used to put logic when user enter text in any Edittext of Listview.

We will pass all the edittext values to next activity so that they can be used as per requirement of app.

Check out the output of Android Listview Edittext With TextView tutorial.

1. Create a model class

Create a new class named “” and copy below code

We will use objects of this model to perfectly retain the edittext value when scrolling listview.

Getter and Setter methods are the key for every mode class. So we have created in this model also.

2. Making ListView Item

Open new resource layout file and give it a name lv_item.xml

This is the complete view of every single row item of listview.

It contains a textview along with edittext.

3. Preparing Custom Adapter

Make a new java class named “”.

Add following into this class


This class is the heart of the whole tutorial.

The main logic is inside this lines of code

When user enter any text value, above method will be called.

Now we are using an ArrayList of the objects of EditModel class. So every single object of EditModel class contains value of edittext.

Now suppose, when user enters the text in the 1st edittext of listview, 1st object from ArrayList is called and the value of edittext is updated in that. Thus when user scrolls the listview, again listview will be populated and updated value of 1st edittext will be printed.

The ArrayList is defined as public static, so that it can be used in any other activity.

4. Changing MainActivity

Change you class as per below

ListView is populated in MainActivity with the object of customAdapter class.

Button click event is also defined in above class.

Update your activity_main.xml

Add below code

5. NextActivity Creation

Make a new activity and give it a name “NextActivity”

Now write following source code into class

This class simply prints the text valued of all the edittexts.

We have used ArrayList of the objects of EdiModel class which was defined in CustomAdapter.

Add below into activity_next.xml

Thus, you have seen that implementing a custom listview with edittext and textview is not big deal.

It is also easy to retain the value even when user scrolls the listview.

And finally, getting values of edittexts to any other future activities is also not complex.

Similar Tutorials

If you want learn some other easy listview tutorials then read:

Android ListView CheckBox Example

Android Listview Button Tutorial 

Thanks for reading this tutorial.

Download Source Code For Android ListView EditText Tutorial

[sociallocker]Download Listview_edittext Source Code[/sociallocker]

Hardik Parsania

I am mobile app developer. I am always passionate about solving complex and real world problems.I have developed many apps with great interest and superior logical skills.

You may also like...

9 Responses

  1. Lucas Gomes says:

    I getting a problem with this code, when i scoll down, my edittext value get duplicate in all other edittext, why ?

    • Hardik Parsania says:

      Download my source code and run in your android studio. Then check if this problem exist or not?
      If not then replace your code with downloaded code

  2. Catalin says: this article is a life saviour. I was struggling with a simmilar problems for 2 days and couldn’t find an answer until this came up.


  3. Khushhal says:

    Thank you Man. I was working from last 3-4 hours and this line
    “public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

    }” save my life :P.

    Thanks again

  4. asep supratman says:

    nice tutorial…
    can you explain, if we use 2 or more EditText ..
    thank before…

  5. asep supratman says:

    Thank you, this is nice tutorial…
    how if we use 2 or more EditText in ListView..?

  6. Gabriel says:

    How can we get back input and set randomly a text with one of input ?

Leave a Reply

Your email address will not be published. Required fields are marked *