changing content of text view on button click inside listview
<p><a href="http://i.stack.imgur.com/sxbm3.png" rel="nofollow">this is the image of layout tile.xml</a>
i have created a list using custom adapter it has 2 textviews and 2 buttons inside it now what i want is to change the visiblity of one of textview on button click.</p>

<p>I am handling the button clicks outside the custom adapter.I want to toggle visiblity toggle for second textview with id tvstatus using on and off buttons.</p>

<p>this is code for customadapter</p>

<pre><code>package slide.apptech.com.rpiconnect;

/**
 * Created by MOHIT on 09-06-2016.
 */
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import java.util.ArrayList;

//custom adapter class extends a arrayadapter
public class customadapter2 extends ArrayAdapter&lt;String&gt; {
    private final Context context;
    private final ArrayList values;
    private String stv = "Ststus";

    public customadapter2(Context context, ArrayList values) {

        //for super constructor pass
        // context files
        //layout file required for list
        //arraylist that has strings to be displayed
        super(context, R.layout.tile, values);
        this.context = context;
        this.values = values;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        final int pos = position;
        final ViewGroup par = parent;
        LayoutInflater inflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View rowView = inflater.inflate(R.layout.tile, parent, false);
        final TextView textView = (TextView) rowView.findViewById(R.id.tvappname);
        Button on = (Button) rowView.findViewById(R.id.bon);
        Button off = (Button) rowView.findViewById(R.id.boff);
        final TextView status = (TextView) rowView.findViewById(R.id.tvstatus);

        on.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                status.setVisibility(View.VISIBLE);
                notifyDataSetChanged();
                ((ListView) par).performItemClick(v, pos, 0); // Let the event be handled in onItemClick()

            }
        });

        off.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) ;
                ((ListView) par).performItemClick(v, pos, 0); // Let the event be handled in onItemClick()
            }
        });

        //get(position method is used to access the elements of arraylist)
        String val = (String) values.get(position);
        textView.setText(val);
        // Change the icon for Windows and iPhone
        String s = (String) values.get(position);

        return rowView;
    }

    public void myClickHandler(View v)
    {

    }
}
</code></pre>

<p>this is code for my xml file that i am using as listelement</p>

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


    &lt;android.support.v7.widget.CardView
        xmlns:card_view="http://schemas.android.com/apk/res-auto"
        android:id="@+id/card_view"
        android:layout_gravity="center"
        android:layout_width="match_parent"
        android:layout_margin="2dp"
        android:layout_height="100dp"
        card_view:cardCornerRadius="4dp"
        android:layout_alignParentStart="true"
        android:background="#611818"
        android:paddingBottom="10dp"&gt;

        &lt;RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"&gt;
        &lt;Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="OFF"
            android:id="@+id/boff"
            android:layout_alignParentBottom="true"
            android:layout_alignParentStart="true"
            android:layout_marginStart="37dp"
            android:focusable="false"/&gt;

        &lt;Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/bon"
            android:text="ON"
            android:layout_alignParentBottom="true"
            android:layout_alignParentEnd="true"
            android:layout_marginEnd="28dp"
            android:focusable="false"/&gt;

        &lt;TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Ttile"
            android:id="@+id/tvappname"
            android:textSize="20sp"
            android:layout_above="@+id/boff"
            android:layout_centerHorizontal="true"
            android:textColor="@color/abc_input_method_navigation_guard" /&gt;

            &lt;TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="ON"
                android:id="@+id/tvstatus"
                android:layout_below="@+id/tvappname"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="20dp"
                android:textColor="#060505"
                android:visibility="invisible"/&gt;


        &lt;/RelativeLayout&gt;
    &lt;/android.support.v7.widget.CardView&gt;


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

<p>please comment if you want any other file</p>