ListView onItemClick水平进度条

时间:2014-01-11 12:45:49

标签: android progressdialog

当然这应该有用吗?我只得到一个圆形不确定的微调器。我做错了什么!?

 // Assume oListElements is a list of strings
 ArrayAdapter<String> oArrayAdapter  = new ArrayAdapter<String> (this,android.R.layout.simple_list_item_1,oListElements);
 oListView.setAdapter(oArrayAdapter);

@Override
public void onItemClick(AdapterView<?> oArg1, View oView, int iInt1, long iInt2)
{
    /*
     * Also tried:
     * ProgressDialog oProgressDialog = new ProgressDialog(this,ProgressDialog.STYLE_HORIZONTAL);
     */
    ProgressDialog oProgressDialog = new ProgressDialog(this);
    oProgressDialog.setProgress(ProgressDialog.STYLE_HORIZONTAL);
    oProgressDialog.setMax(100);
    oProgressDialog.setMessage("PD Message");
    oProgressDialog.show();
}

如果您需要,我的XML很简单:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".TrainingMode" >

    <ListView
        android:id="@+id/scroll_view_listview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        >

    </ListView>

</RelativeLayout>

忽略这一点,我只需要绕过愚蠢的Stack Overflow代码/单词检查。 Blah blah blah blah blah blah。

1 个答案:

答案 0 :(得分:0)

使用ProgressDialog.setIndeterminate使进度条不确定并使用ProgressDialog.setProgressStyle(而不是ProgressDialog.setProgress)强制进行水平布局:

oProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
oProgressDialog.setIndeterminate(false);