java - android spinner change the background color for specific items -
i have spinner , want change background color specific items. mean if object named: country , if have value section=true
item of spinner have background color = blue
.
@override public view getview(int position, view convertview, viewgroup parent) { final kamcoreporttype report = values.get(position); if (convertview == null) { context mcontext = this.getcontext(); layoutinflater vi = (layoutinflater) mcontext.getsystemservice(context.layout_inflater_service); textview tv=(textview) convertview.findviewbyid(r.id.textview01); if (report.issection()) tv.setbackgroundcolor=blue //what ever
how can that.
on getview()
method can do:
if (yourcondition) { tv.setbackgroundcolor(getcontext().getresources().getcolor(r.color.blue)); }
this should trick.
@update
if got right, want current item on getview()
method, right?
i assume adapter extending arrayadapter<t>
. if case, can items using arrayadapter getitem(position)
method , test like:
if ((getitem(position)).issection()) { }
inside getview()
.
hope helps.
Comments
Post a Comment