ListView Updating a single row
<p>I want to update a single row in my listview with different content once i press a button. I know i can use <code>notifydatasetchanged(</code>) but that would update the whole <code>listView</code>.</p>

<p>I have read this <a href="http://stackoverflow.com/a/9987616/1552551">answer</a> and it fits perfectly for what I want to do. </p>

<p>I have done a listview with 5 rows and when I press the button I want to update the 4th row with a different text. I dont want to set the text programatically since this is just a dummy project just to see if refreshing a single row is possible and my real project is much more complex than just a <code>textview</code>.</p>

<p>So my question is: can i use <code>getView()</code> to update a single row in a <code>listview</code>?</p>

<p>Here is my code:</p>

<p><em>my Activity:</em></p>

<pre><code>public class MainActivity extends Activity {

    public ListView list1;
    public listAdapter adapter;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        list1 = (ListView) findViewById(R.id.my_list);
        adapter = new listAdapter(this);
        list1.setAdapter(adapter);

        Button button1 = (Button) findViewById(R.id.my_button);
        button1.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                adapter.setText("Different text");
                View row2Update = list1.getChildAt(3);
                list1.getAdapter().getView(3, row2Update, list1);

            }
        });

    } 

}
</code></pre>

<p><em>My adapter :</em> </p>

<pre><code>public class listAdapter extends BaseAdapter{

    public Activity activity;
    public String text="Normal Text";

    public listAdapter(Activity activity){

        this.activity = activity;
    }

    public void setText(String text){
        this.text = text;
    }

    public int getCount() {
        return 5;
    }

    public Object getItem(int position) {

        return null;
    }

    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return 0;
    }

    public View getView(int position, View convertView, ViewGroup parent) {
        LayoutInflater inflater = activity.getLayoutInflater();
        LinearLayout rowView = (LinearLayout) inflater.inflate(R.layout.row_layout, null);
        TextView textView = (TextView) rowView.findViewById(R.id.row_text);
        textView.setText(text);
        return rowView;
    }

}
</code></pre>

<p>This is what the activity looks like:</p>

<p><img src="http://i.stack.imgur.com/ZRNB8.png" alt="Activity snapshot"></p>

<p>But when I press my button nothing changes</p>
