1
我的項目是下載PDF,然後查看它。 https://stackoverflow.com/a/24748227/8769785如何添加進程按鈕以顯示按鈕上的下載進度?
我想顯示在下載按鈕下載進度![從提供和URL「下載」按鈕,下載「查看」按鈕,打開文件]
我當正在下載文件(進度)時,要在「下載按鈕」中添加「提交處理按鈕」動畫。
我的問題是我不知道如何獲得下載按鈕上的動畫(進度)。
在該項目中有一個「Filedownloader」類 我已經嘗試了與主要活動的點擊偵聽器,但我仍然無法獲得按鈕上的進度。我無法從網址取得進展。
我是Android編程新手。
的代碼是這樣
//獲取按鈕視圖 SubmitProcessButton btnSubmit按鈕=(SubmitProcessButton)findViewById(R.id.btnSubmit);
//start with progress = 0
btnSubmit.setProgress(0);
//to test the animations, when we touch the button it will start counting
btnSubmit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
SubmitProcessButton btn = (SubmitProcessButton) view;
// we add 25 in the button progress each click
if(btn.getProgress() < 100){
btn.setProgress(btn.getProgress() + 25);
}
}
});
使用'AsyncTask'來顯示從服務器下載數據時的進度。 –
在該項目中有一個filedownloader類可幫助下載文件。我不確定在哪裏添加setprogress。 –
使用對話框甚至TextView,跟蹤進度以及更新值可以是一個解決方案 – rmjoia