Q:

Textview duplication in custome listview

I have a custom list view with base adapter.In the listview each item contain button and a textview,I want to visible the textview when clicking on the corresponding button.It is working bt my problem is that when i click on the button the textview is visible in more than one item.Please suggest any solution.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    if (convertView == null) {
        // convertView = new View(context);
        convertView = inflater.inflate(R.layout.secondadapter, null);
    }

holder.ans=(Button)convertView.findViewById(R.id.btn_ans);
holder.textview=(TextView)convertView.findViewById(R.id.txt_ans);

holder.ans.setOnClickListener(new OnClickListener() {
   @Override
    public void onClick(View v) {

holder.textview.setText("Answer is correct");

}
});

}
public class Holder
{
TextView textview;
Button ans;
}

A:

Try this code.
    @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            if (convertView == null) {
    // convertView = new View(context);
    convertView = inflater.inflate(R.layout.secondadapter, null);
    holder.ans=(Button)convertView.findViewById(R.id.btn_ans);
    holder.textview=(TextView)convertView.findViewById(R.id.txt_ans);
    convertView.setTag(holder);

}else{
        holder=(holder)convertView.getTag();
}

      if(!isTextViewVisible[position]) {  holder.textview.setVisibility(View.Invisible); }
else {
holder.textview.setVisibility(View.visible); 
}
holder.ans.setOnClickListener(new OnClickListener() { 
@Override 
public void onClick(View v) 
{ 
holder.textview.setText("Answer is correct");    isTextViewVisible[position] = true; 
} });

    }
    public class Holder
    {
    TextView textview;
    Button ans;
    }

