English 中文(简体)
1. 根据获得意见的方法中的数据确定图像
原标题:Set image based on data in getView() method

Index,Gainers,Losers are the 3 buttons。 On each button click, listView gets populated with corresponding data。

第3栏:编码 可查阅negative或active

基于<代码>%Chg数值,对应的<代码> 页: 1 意见后附<>%Chg。 up arrow for active Value and down arrow for negative Value

。 点击<代码>%Chg栏内一个阵列中的Im 转值,名称为updownAdapter。 班级

Based on that value, Adapter should set the down arrow or up arrow

www。un。org/Depts/DGACM/index_spanish。htm 适应性班(植物学)法

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。。。

www.un.org/Depts/DGACM/index_spanish.htm 如何向每一行展示相应的arrow?

I m new to android development。 So ANY HELP WILL BE LIFE-SAVER !!!

screen

最佳回答
if (i < updown.length) {
        if (updown[i] > 0) 
            holder.ivarrow.setImageResource(R.drawable.up);
        else 
            holder.ivarrow.setImageResource(R.drawable.down);
        Log.v("i=", i + " ,updown=" + updown[i]);
        i++;
    }

replace your code with :

if (updown[position] > 0) 
            holder.ivarrow.setImageResource(R.drawable.up);
        else 
            holder.ivarrow.setImageResource(R.drawable.down);

我认为这有利于你们。

问题回答

暂无回答




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...