2013-10-11 91 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