2013-10-11 59 views
0

我有一項服務將廣播發送到顯示網格中 中的項目列表的活動。一個特定的網格項目有一個圖像和一個進度條,它應該在 廣播接收機上更新。該活動已在接收器中註冊並顯示日誌。進度條始終設置爲最大

當發送廣播時,接收器更新圖像,並且可以設置圖像的alpha值,但不能更新進度條的進度。進度條始終設置 最大的關注是在接收器


View v = bookgrid.getChildAt(0); 
ProgressBar progress = (ProgressBar)v.findViewById(R.id.book_progress); 
RelativeLayout rl = (RelativeLayout)v.findViewById(R.id.book_image); 
progress.setVisibility(View.VISIBLE); 
rl.setAlpha((float) 0.2); 
progress.setProgress(30); 

回答

0

我相信你正在嘗試使用基於0-100進步的代碼。對於你必須設置進度最大值爲100的第一

http://developer.android.com/reference/android/widget/ProgressBar.html#setMax(int)

改變你的代碼

View v = bookgrid.getChildAt(0); 
ProgressBar progress = (ProgressBar)v.findViewById(R.id.book_progress); 
RelativeLayout rl = (RelativeLayout)v.findViewById(R.id.book_image); 
progress.setVisibility(View.VISIBLE); 
rl.setAlpha((float) 0.2); 
progress.setMax(100); 
progress.setProgress(30); 
+0

默認情況下,雖然進度條最大值爲100 ..你也應該檢查是否已設置它代碼中的其他內容 – Shubhank