Reputation: 3496
My ListView
is set to singleChoice
mode, the item view contains a Button
. If I select the list item, the Button
changes to visible.
When the list item is unselected the Button
set to gone. How can I do that?
It is similar to the change of background color.
actually, my list item contains a textView and a delete button, the delete button are visible only when the item is selected
Upvotes: 0
Views: 852
Reputation: 16398
Use setOnItemClickListener()
method
listView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Button b = (Button) view.findViewById(R.id.button_id);
if(b.getVisibility() == View.VISIBLE)
b.setVisibility(View.INVISIBLE);
else
b.setVisibility(View.VISIBLE);
}
});
Upvotes: 2