简体   繁体   中英

How to make a Image visible on a particular row in a Listview generated using SimpleAdapter?

I am trying to set an Imageview visible only on particular rows in a Listview which is generated using a Simpleadapter . I want to make an ImageView visible only on selected rows of the ListView ie 2 and 4 when that particular row is clicked. I am getting the position from the onItemClickListener. I just want to know how to set it at a particular row. I want to continue with SimpleAdapter itself. Can any one guide me step by step what to do?

You can use an entity class to define getter and setters for variables. now define a variable showHide image and generate its getter and setter. Now in coustom arrayAdapter in getview method add condition

if(getShowHide(){
Image.setVisibility(View.Visible);
}
else{
Image.setVisibility(View.Gone);
}

Now onitem click set ShowHide to true for that position and call notify datasetchanged() on adapter.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM