I have a list view containing three textviews and one imageview. The visibilty of one of the textview is sets to 'GONE' in the xml.
However, When i click on the imageview i expect the text in the listview to become visible. This is working but rather than make visible only the textview on that row, the text view of another row is showing also.
How do i make only the textview of a row to become visible when i click on that row?
Here are my codes
public class CustomListAdapter2 extends ArrayAdapter<ObjectItem> {
//to reference the Activity
private final Activity context;
private ObjectItem[] data = null;
public CustomListAdapter2(Activity context, ObjectItem[] data) {
super(context, R.layout.most_lodged_complaints, data);
this.context = context;
this.data = data;
}
public View getView(int position, View view, ViewGroup parent) {
if (view == null) {
LayoutInflater inflater = context.getLayoutInflater();
view = inflater.inflate(R.layout.most_lodged_complaints, parent, false);
}
final ObjectItem objectItem = data[position];
TextView headerTextField = (TextView) view.findViewById(R.id.list_header);
TextView detailTextField = (TextView) view.findViewById(R.id.list_detail);
final TextView textView = (TextView) view.findViewById(R.id.list_detail2);
ImageView imageView = (ImageView) view.findViewById(R.id.most_complaints_expand);
headerTextField.setText(objectItem.header);
detailTextField.setText(objectItem.detail);
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
textView.setVisibility(View.VISIBLE);
}
});
return view;
};
}
Note: I've tried using the ViewHolder pattern and the problem persist