[英]Create Dialog Box with Progress Bar in android
我已經成功創建了一個自定義對話框。 對話框工作正常。 我正在使用ListView
列出特定路徑中的所有文件。 我的自定義對話框包含文件名和復選框。 所選文件可以移動或刪除。 所有這些都很好。
我需要在對話框中添加進度欄。 由於可以刪除或移動文件,需要一些時間。 如何添加進度欄。 請幫我。
屏幕截圖示例:-(如何添加綠色的進度條)
謝謝。
Bala將您創建為對話框的自定義布局插入帶有自定義顏色的Horizontal SCrollBar中具有綠色的水平progressBar的代碼。
您已經寫了您知道如何創建自定義對話框的信息,但我想先發布它:
final Dialog dialog = new Dialog(MyActivity.this, R.style.CustomDialogTheme);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.info_dialog);
dialog.setTitle("Info");
dialog.setCancelable(false);
Button deleteButton = (Button) dialog.findViewById(R.id.deleteButton);
ProgressBar progressBar = (Button) dialog.findViewById(R.id.progressBar);
deleteButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// start progress
}
});
dialog.show();
並供info_dialog.xml文件使用
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ProgressBar
android:id="progressBar"
style="@android:style/Widget.ProgressBar.Horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.