code to custom list adapter view (this list has only 11 items) and viewholder is 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 ){ // for 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
so if single_transaction_value < 0 color of textview changes to #098AAA(light green)
color is not changing as expected .
Note that color of top bar is correct. grey color for phone number. text on white background . skyblue or lightgreen color of transaction depending on if condition. Strange behaviour is in color changing from default skyblue defined in xml to lightgreen defined in code.
Now here comes a little change in if condition, added an else
if(single_transaction_value < 0) {
transaction.setBackgroundColor(Color.parseColor("#098AAA"));
}
else {
transaction.setBackgroundColor(Color.parseColor("#76BB51"));
}
now color is changing as expected.
how is this..