android - How to change the particular row colour of listview -


i have listview of notification ,i want if user click on notification(particular row) color should change. changing color means notification read. changed color should reflect if app restarts.

for have write code in class extending array adapter.

 @override public view getview(int position, view v, viewgroup parent) {     view mview = v ;     if(mview == null){         layoutinflater vi = (layoutinflater)mcontext.getsystemservice(context.layout_inflater_service);         mview = vi.inflate(id, null);     }     listview=(listview)mview.findviewbyid(r.id.notiid);     string sd= yorn.get(position);     if(sd=="y"){         listview.getchildat(position).setbackgroundcolor(color.green);     } 

i have used debugger , getting condition in if loop true, problem not getting changed color lisview. debugger not moving in if loop.

any ideas?

you should using recyclerview instead of listview start off with. in adapter recyclerview check position in onbindviewholder , set background colour of row accordingly. see below.

 @override public void onbindviewholder(customviewholder holder, int position) {     if(position == 2){         holder.ll_item_background.setbackgroundcolor(mcontext.getresources().getcolor(r.color.calc_boxes));     }       // stuff here } 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -