我想要有一個ProgressDialog
確定進度欄,而不是默認微調器。這似乎很容易:ProgressDialog
有方法setIndeterminate
,方法show
接受布爾值來指示不確定性。但這些方式對我不起作用!該對話框仍然與微調不確定。如何改變行爲?在Android中確定ProgressDialog
5
A
回答
9
您需要致電:
progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
查看官方開發指南Showing a progress bar與連接到該部分的示例源代碼。
-2
ProgressDialog dialog = new ProgressDialog(this);
dialog.setMessage("Registering. Please wait...");
dialog.setIndeterminate(true);
dialog.setCancelable(false);
dialog.show();
Try this code should work fine...
+1
我想你誤解了我:我需要確定的進度條,它顯示完成了多少過程。 – aplavin 2012-03-31 13:59:52
0
Oh Sorry.. Try this
1) Create a layout file with below code
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:id="@+id/RelativeLayout_DownloadProgress" android:paddingLeft="20dp" android:paddingBottom="20dp" android:paddingRight="10dp" android:paddingTop="20dp">
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/downloading_video_tv" android:text="@string/downloading_video" android:textStyle="bold" android:textColor="@color/COLOR_WHITE"></TextView>
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/download_progress_tv" android:text="@string/zero_percent" android:layout_below="@+id/downloading_video_tv" android:textColor="@color/COLOR_WHITE"></TextView>
<Button
android:id="@+id/download_cancel_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@+id/downloading_video_tv"
android:text="@string/Cancel"
android:textColor="@color/COLOR_CANCEL_BTN" android:layout_marginLeft="5dp">
</Button>
<ProgressBar
android:id="@+id/download_progressbar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent"
android:layout_height="13dp"
android:layout_below="@id/download_progress_tv"
android:layout_toLeftOf="@id/download_cancel_btn"
android:indeterminateOnly="false"
android:max="100"
android:progressDrawable="@drawable/dwnld_progress" >
</ProgressBar>
</RelativeLayout>
2) In your code do the following
i) in oncreate() method add the following lines..
//Download progress layout inflate
RelativeLayout relativelayout_DownloadProgress = (RelativeLayout)_inflater.inflate(R.layout.downloadprogress, null);
TextView downloadProgress_PercentageTV = (TextView)relativelayout_DownloadProgress.findViewById(R.id.download_progress_tv);
Button downloadProgress_CancelBtn = (Button)relativelayout_DownloadProgress.findViewById(R.id.download_cancel_btn);
ProgressBar download_progressBar = (ProgressBar)relativelayout_DownloadProgress.findViewById(R.id.download_progressbar);
downloadProgress_CancelBtn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
dismissDialog(0);
}
});
ii) //Creating Dialogs i.e., below onCreate() method
protected Dialog onCreateDialog(int id) {
switch (id) {
case 0:
return new AlertDialog.Builder(_activity)
.setView(relativelayout_DownloadProgress)
.create();
}//switch end
return null;
}//onCreateDialog()
iii) on any click event add the following lines.
showDialog(0);download_progressBar.setProgress(0);
Sorry i know its too long code but its working code in application...Try it might need modifications like variables must be declared in class scope.
相關問題
- 1. 如何ProgressDialog在Android中
- 2. Android在OnResume中顯示ProgressDialog()
- 3. 開發自定義progressdialog android
- 4. 如何自定義Android ProgressDialog?
- 5. Android自定義ProgressDialog動畫
- 6. Android的全球定位系統的AsyncTask和ProgressDialog不確定
- 7. Android ProgressDialog
- 8. Android ProgressDialog卡在onResponse
- 9. android-ProgressDialog中的CountDownTimer
- 10. Android:我如何更改不確定的ProgressDialog消息的字體
- 11. Android ProgressDialog with setContentView
- 12. 顯示ProgressDialog Android
- 13. Android Force Close ProgressDialog
- 14. 如何使用ProgressDialog在android
- 15. ProgressDialog不顯示在android
- 16. Android中的ProgressDialog解僱
- 17. Android中的ProgressDialog for new Activity
- 18. 在Android中搜索時顯示ProgressDialog
- 19. 將不會在android中顯示progressDialog
- 20. 在android中更改progressdialog和alertdialog背景?
- 21. 如何在Android中顯示progressDialog?
- 22. ProgressDialog不會出現在Android中
- 23. android在構造函數中創建ProgressDialog
- 24. Android調用自定義ProgressDialog - 如何?
- 25. 風格爲Android ProgressDialog
- 26. Android ProgressDialog不旋轉
- 27. Progressdialog慢於Android的
- 28. 的Android ProgressDialog風格
- 29. android ProgressDialog - 需要onClickListener?
- 30. 在任何類中動態顯示Android自定義ProgressBar或ProgressDialog
這個鏈接的例子確實有幫助,謝謝) – aplavin 2012-04-01 18:42:15