[英]How to Disable control till Progress Bar is active
I have kept progressbar visibility to invisible
from xml. 我一直保持进度条可见性从xml invisible
。 Its respective activity have a Asynch Task when in onPreExecute
its visibility is turn out to visible
and invisible
in onPostExecute
. 其各自的活动有一个非同步任务时onPreExecute
其可见性变成visible
和invisible
的onPostExecute
。 All working fine, however I want my other view control remains disable till progressbar is visible. 一切正常,但是我希望其他视图控件保持禁用状态,直到进度条可见。
Xml XML
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
style="?android:attr/progressBarStyleInverse"
android:visibility="invisible" />
Thanks in Advance 提前致谢
You are having a Asynch Task, it should have the following methods :- 您正在执行“异步任务”,它应具有以下方法:-
@Override
protected void onPostExecute(String result) {
// Disable the progress bar
progress.setVisibility(false);
// Enable all the views that you have disabled earlier in onPreExecute
view1.setEnable(true);
}
@Override
protected void onPreExecute() {
// start progress bar here
progress.setVisibility(true);
// Disable all your views here
view1.setEnable(false);
}
@Override
protected void onProgressUpdate(Void... values) {
}
Here progress is an object of ProgressBar and view1 will be your viewgroup it may be a Imageview, Textview or anything else. 这里progress是ProgressBar的对象,view1将是您的视图组,它可以是Imageview,Textview或其他任何对象。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.