Android进度条不动

时间:2014-11-25 06:29:53

标签: android progress-bar

我在ProgressBar下面使用了以下代码,它在Simple Activity上工作正常但在ListView中却没有,任何人都建议我

需要与图片相同

Sample Image

在listview中得到这样的结果

Below code got this in listview

这是我的代码:

class StatsAdapter extends BaseAdapter{
    LayoutInflater li;
    Context dctx;
    LinearLayout item;
    ProgressBar p;
    ObjectAnimator animation;
    public StatsAdapter(Context c) {
        this.dctx = c;
    }

    @Override
    public int getCount() {
        return 10;
    }

    @Override
    public Object getItem(int arg0) {
        return arg0;
    }

    @Override
    public long getItemId(int arg0) {
        return arg0;
    }

    @Override
    public View getView(int arg0, View view, ViewGroup arg2) {
        li = (LayoutInflater)dctx.getSystemService(LAYOUT_INFLATER_SERVICE);
        view = li.inflate(R.layout.stats_listitem, null);
        item = (LinearLayout)view.findViewById(R.id.item_layout);
        p = (ProgressBar) view.findViewById(R.id.progressBar1);
        p.getProgressDrawable().setColorFilter(Color.rgb(220, 41, 82), Mode.SRC_IN);
        animation = ObjectAnimator.ofInt(p, "progress", 16); 
        animation.setDuration(500); // 0.5 second
        animation.setInterpolator(new DecelerateInterpolator());
        animation.start();
        //p.setProgress(50);
        if(arg0%2==1){
            item.setBackgroundColor(Color.rgb(252, 234, 238));
        }
        return view;
    }

}

这是我的XML:

   <ProgressBar
       android:id="@+id/progressBar1"
       style="?android:attr/progressBarStyleHorizontal"
       android:layout_width="match_parent"
       android:layout_height="15dp" />

0 个答案:

没有答案