How to set image in custom listview in Android? -
I am developing an application in which I will have to show ratings based on prices which can pars me in the XML response Receiving the list view afterwards. I've shown images using this custom adapter and getView () method:
string rating = static Menu.RatingList.get (status); If (rating angle ("1")) {rateImg1.setImageResource (R.drawable.stary); } The problem occurs when I scroll down to the previous object and then move upwards, it is recreating the list line
Someone suggested stop approaching me to close the list row and set the image value permanently.
How do you rate the rate Img1? Maybe you should take it from the scene that has been passed by the getView () method? Something like this:
see public getView (int position, view view, viewgroup parent) {if (view == null) {view = LayoutInflater.from (ctx) .inflate (R. Layout .my_layout, guardian, wrong); } ((ImageView) view.findViewById (R.id.my_image)). SetImageResource (R.drawable.some_drawable); Return view; } In addition you can apply GetViewTypeCount () and getItemViewType () and in the above method they can not delete the same image again if it is already set.
Comments
Post a Comment