android - Strange Behaviour of backgroundcolor in custom listview (nolarge dataset) -


code custom list adapter view (this list has 11 items) , viewholder not helping here.

@override  public view getview(int position, view convertview, viewgroup parent){     layoutinflater inflater  = (layoutinflater) context.getsystemservice(context.layout_inflater_service);     if( convertview == null ){ // fast view google io http://www.youtube.com/watch?v=wdbm6wveo70     convertview = inflater.inflate(r.layout.single_transaction,parent,false);     }     textview phone_number = (textview) convertview.findviewbyid(r.id.phone_number_show);     textview transaction_summary = (textview) convertview.findviewbyid(r.id.transaction_summary_show);     textview transaction = (textview) convertview.findviewbyid(r.id.transaction_show);      transactions single_transaction = (transactions)  getitem(position);      phone_number.settext(string.valueof(single_transaction.get_phone_number()));     transaction_summary.settext(single_transaction.get_transaction_summary());      int single_transaction_value = single_transaction.get_transaction();      if(single_transaction_value < 0) {          transaction.setbackgroundcolor(color.parsecolor("#098aaa"));     }      transaction.settext(string.valueof(single_transaction_value));      return convertview;  } 

here if condition alters default color(skyblue) of textview defined in xml
if single_transaction_value < 0 color of textview changes #098aaa(light green)
color not changing expected .

note color of top bar correct. grey color phone number. text on white background . skyblue or lightgreen color of transaction depending on if condition. strange behaviour in color changing default skyblue defined in xml lightgreen defined in code.

now here comes little change in if condition, added else

if(single_transaction_value < 0) {          transaction.setbackgroundcolor(color.parsecolor("#098aaa"));     } else {         transaction.setbackgroundcolor(color.parsecolor("#76bb51"));     } 

now color changing expected.

how this..


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -