小编Dek*_*kar的帖子

使用ProgressBar.setProgressDrawable时出现问题

使用setProgressDrawableProgressBar具有自定义颜色不给我们以正确的方式工作.我们在a的行中使用progressbars ListView,但仅当列表中有多个元素时才会显示进度.如果是一个元素,则进度条为空.

CursorAdapter.java:

public class CursorAdapter extends SimpleCursorAdapter {
    public CursorAdapter(Context context, int layout, Cursor c, String[] from,
            int[] to) {
        super(context, layout, c, from, to);
    }

    public void bindView(View view, Context context, Cursor cursor) {
        super.bindView(view, context, cursor);
        updateProgressbar(view, cursor);
    }

    /**
     * This method updates the progressbar using the "numberpages" and
     * "currentpage" values. 
     */
    private void updateProgressbar(View view, Cursor cursor) {
        ProgressBar progressBar = (ProgressBar) view
                .findViewById(R.id.progressbarHorizontal);

        progressBar.setProgressDrawable(view.getResources().getDrawable(
                R.drawable.greenprogress));

        progressBar.setMax(cursor.getInt(cursor.getColumnIndex("numberpages")));
        progressBar.setProgress(cursor.getInt(cursor
                .getColumnIndex("currentpage"))); …
Run Code Online (Sandbox Code Playgroud)

xml android android-progressbar progress-bar

3
推荐指数
1
解决办法
4710
查看次数

标签 统计

android ×1

android-progressbar ×1

progress-bar ×1

xml ×1