In my application, there is an image in the list view, change the image's image to another. I can identify which image has been clicked and it can be given a new image. After doing this properly it will not change the image after reloading it. How can I change the image without reloading?
My program section status_id will show the return value of 0 or 1
holder.favorite.setOnClickListener (New View.OnClickListener) {Public Zero onClick (see v) { The string is the integer.toString (position) of the integer status_id; holder.favorite.setImageResource (0); status_id = change_status_of_Favorite (channel- [status], channelfavo [position]); if (status_id == 0) {channelFavo [position ] = "False"; holder.favorite.setImageResource (R.drawable.favorite_gray); Toast.makeText (activity, "Excluded from Favorites", Toast.LENGTH_SHORT) .show ();} else {ChannelFavo [status] = " True "; holder.favorite.setImageResource (R.drawable.favorite_icon); Toast.makeText (Activity B, "Favorite Added", Toast.LENGTH_SHORT) .show ();} //Toast.makeText(activity, "position:" + S, toast.LENGTH_SHORT) .show (in);}});
OK, check my code if you want to do with toggle buttons Create new xml / drawable / imagefile.xml in race
& lt ;? Xml version = "1.0" encoding = "UTF-8" & gt; & Lt; Selector xmlns: Android = "http://schemas.android.com/apk/res/android" & gt; & Lt; Item Android: Drauble = "@ Drable / Off" /> & Lt ;! - default - & gt; & Lt; Item Android: state_checked = "true" android: drawable = "@drawable / on" /> & Lt ;! - pressed - & gt; & Lt; Item android: state_checked = "false" Android: drawable = "@ drawable / off" /> & Lt ;! - uncheck - & gt; & Lt; / Selector & gt; Now you create toggle buttons in
Android: ToggleButton Android: id = "@ + id / btn" Android: layout_width = "wrap_content" Android : Layout_height = "wrap_content" android: layout_gravity = "top" android: texton = "" android: textoff = "android: background =" @drawable / imagefile "/> with In the activity you perform on FlashOnoff.Setbackground Resource (R.drawable.off); or FlashOnAff .SetbackgridResource (R.drawable.on); You can also set this situation using, but move There is a need to create just new boolean violet to maintain / stop. I hope this will help you.
Thanks.
Comments
Post a Comment