How to use viewHolder to make listView user input not go back to default when scrolling off screen
<p>I have a listView where a user can enter input to change the textView on each listView row. When you scroll the row off the screen the edited text goes away and the default text reappears. I know this is fixed with the viewHolder but I can't get it to work in my custom adapter class.</p>

<p>MainActivity.java</p>

<pre><code>import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.app.Activity;
import android.view.KeyEvent;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ViewSwitcher;

import java.util.ArrayList;

public class MainActivity extends Activity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        final ArrayList&lt;String&gt; Chores = new ArrayList&lt;&gt;();
        //Chores.add("");

        final ListAdapter MyAdapter = new CustomAdapter(this, Chores);
        ListView listViewObject = (ListView)findViewById(R.id.customListView_ID);
        listViewObject.setAdapter(MyAdapter);

        listViewObject.setOnItemClickListener(
            new AdapterView.OnItemClickListener(){
                @Override
                public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id){
                    String ChoreString = String.valueOf(parent.getItemAtPosition(position));




                }
            }

        );
        final Button button = (Button) findViewById(R.id.button_ID);
        button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                Chores.add("");
                ((ArrayAdapter)MyAdapter).notifyDataSetChanged();

            }

        });




    }
}
</code></pre>

<p>CustomAdapter.java</p>

<pre><code>import android.content.Context;
import android.content.DialogInterface;
import android.support.annotation.NonNull;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.ArrayList;

import static com.example.emilythacker.chorelist.R.id.textView_ID;



class CustomAdapter extends ArrayAdapter{

    ArrayList&lt;String&gt; choreText;

    public CustomAdapter(Context context, ArrayList choreText) {
        super(context, R.layout.custon_listview_row, choreText);
        this.choreText = choreText;
    }

    @NonNull
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        final ViewHolder holder;

        //final TextView textView = (TextView) customView.findViewById(textView_ID);

        if (convertView == null) {
            LayoutInflater layoutInflater = LayoutInflater.from(getContext());
            convertView = layoutInflater.inflate(R.layout.custon_listview_row, null);
            holder = new ViewHolder();
            holder.imageButton = (ImageButton) convertView.findViewById(R.id.imageButton_ID);
            holder.textView = (TextView) convertView.findViewById(textView_ID);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        holder.textView.setText(choreText.get(position));
        holder.textView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //what happens when textView is clicked
                AlertDialog alertDialog = new AlertDialog.Builder(getContext()).create();
                final EditText input = new EditText(getContext());
                input.setHint("hint");
                alertDialog.setView(input);
                alertDialog.setTitle("Set Chore");
                alertDialog.setMessage("Alert message to be shown");
                alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {




                        holder.textView.setText(input.getText().toString());





                        dialog.dismiss();
                    }
                });
                alertDialog.show();

            }
        });



        holder.imageButton.setImageResource(R.drawable.clock);


        return convertView;
    }

    static class ViewHolder {
        ImageButton imageButton;
        TextView textView;
    }
}
</code></pre>

<p>activity_main.xml</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.emilythacker.chorelist.MainActivity"&gt;

    &lt;ListView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/customListView_ID"
        android:layout_alignParentTop="true"
        android:layout_alignParentStart="true"
        android:layout_marginTop="50dp" /&gt;

    &lt;Button
        android:text="Add Chore"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_alignParentStart="true"
        android:id="@+id/button_ID" /&gt;
&lt;/RelativeLayout&gt;
</code></pre>

<p>custon_listview_row.xml</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="horizontal" android:layout_width="match_parent"
    android:layout_height="60dp"&gt;

    &lt;ImageButton
        android:layout_width="60dp"
        android:scaleType="fitCenter"
        app:srcCompat="@drawable/clock"
        android:id="@+id/imageButton_ID"
        android:layout_height="60dp"
        android:background="@null"
        android:layout_alignParentRight="true"
        android:padding="5dp"
        android:layout_weight="1" /&gt;


    &lt;TextView
        android:text="Click here to add chore"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="10"
        android:id="@+id/textView_ID"
        android:textSize="25dp"
        android:layout_centerVertical="true"
        android:layout_toStartOf="@+id/imageButton_ID"
        android:layout_marginEnd="11dp"
        /&gt;


&lt;/RelativeLayout&gt;
</code></pre>