Index,Gainers,Losers are the 3 buttons.
On each button click, listView gets populated with corresponding data.
3rd column %Chg can be negative or positive.
Based on value of %Chg value, corresponding arrow should be displayed in imageView placed after %Chg column value i.e. up arrow for positive value and down arrow for negative value …
On any button click, I’m passing value of %Chg column in an array named updown to Adapter class
Based on that value, Adapter should set the down arrow or up arrow
Code snippet from Adapter class(getView() method)
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
LayoutInflater inflater = activity.getLayoutInflater();
if (convertView == null) {
convertView = inflater.inflate(R.layout.list_table, null);
holder = new ViewHolder();
holder.txtFirst = (TextView) convertView
.findViewById(R.id.FirstText);
holder.txtSecond = (TextView) convertView
.findViewById(R.id.SecondText);
holder.txtThird = (TextView) convertView
.findViewById(R.id.ThirdText);
holder.ivarrow = (ImageView) convertView.findViewById(R.id.ivarrow);
holder.l1 = (LinearLayout) convertView
.findViewById(R.id.tableLayout);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
HashMap<String, String> map = list.get(position);
//Setting the row background
if (count % 2 == 0) {
try {
InputStream is1 = ctx.getAssets().open("cellbg.png");
Drawable d1 = Drawable.createFromStream(is1, "cellbg");
holder.l1.setBackgroundDrawable(d1);
} catch (Exception e) {
throw new Error(" exception in TableListAdapter "
+ e.getMessage());
}
} else {
try {
InputStream is2 = ctx.getAssets().open("cellbg1.png");
Drawable d2 = Drawable.createFromStream(is2, "cellbg1");
holder.l1.setBackgroundDrawable(d2);
} catch (Exception e) {
throw new Error(" exception in TableListAdapter "
+ e.getMessage());
}
}
count++;
//setting the arrow
if (i < updown.length) {
if (updown[i] > 0) {
holder.ivarrow.setImageResource(R.drawable.up);
Log.v("up", "up");
} else {
holder.ivarrow.setImageResource(R.drawable.down);
Log.v("down", "down");
}
Log.v("i=", i + " ,updown=" + updown[i]);
i++;
}
holder.txtFirst.setText(map.get(FIRST_COLUMN));
holder.txtSecond.setText(map.get(SECOND_COLUMN));
holder.txtThird.setText(map.get(THIRD_COLUMN));
return convertView;
}
.
Log is showing correct data but arrow is getting displayed in only 1st row. i.e. if Last value of list is positive, it shows up arrow to 1st row and if Last value of list is negative, it shows down arrow to 1st row…
How to display corresponding arrow to each row??
I’m new to android development. So ANY HELP WILL BE LIFE-SAVER !!!
.

replace your code with :
And I think it Works for you