2012-07-26 82 views
4

我已經成功創建了一個自定義對話框。對話框運行良好。我正在使用ListView列出特定路徑中的所有文件。我的自定義對話框包含文件名和複選框。所選文件可以被移動或刪除。所有這些工作正常。使用進度條創建對話框android

我需要在對話框中添加進度條。由於可以刪除或移動文件需要一些時間。如何添加進度條。請幫幫我。

示例截屏圖: - (如何添加進度條綠色)

enter image description here

謝謝。

+0

檢查,這可能是這適合你的問題 http://stackoverflow.com/questions/7307736/android-dialog-box-creation-with-progress-bar – 2012-07-26 10:56:46

+0

你問怎麼添加和更新進度欄? – Sam 2014-02-26 12:14:28

回答

3

巴拉您已爲對話創造了自定義佈局插入的水平進度具有色綠從Horizontal SCrollBar with Custom Color.

+0

將它插在兩個按鈕上方刪除並移動。 – AkashG 2012-07-26 10:57:35

+0

AkashG請解釋一下,我們將在'btnDelete.setOnClickListener'上放置什麼代碼。給我示例代碼部分來指導我。 – Bala 2012-07-26 11:24:07

+0

在刪除按鈕你必須實現file.delete()以刪除您選擇的特定文件。 – AkashG 2012-07-26 11:52:11

2

你已經寫你知道如何創建一個自定義對話框中的代碼,但我想先張貼:

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> 
+0

編碼器我在自定義對話框中添加了一個進度條。我們可以在刪除按鈕中使用什麼代碼來處理進度條。引導我。 – Bala 2012-07-26 11:39:07

+0

請看我編輯的帖子。你可以做點deleteButton的東西。如果您使用胎面或其他東西進行刪除,您應該結束線程完成的進度。進一步的信息,你可以看看這裏:http://www.mkyong.com/android/android-progress-bar-example/ – 2012-07-26 11:57:54

+0

ThanksParadise。謝謝。 – Bala 2012-07-27 09:53:53