Android ProgressBar不会出现,也不会显示任何进展
我已经试了一段时间了,看了几篇这样的帖子,就到了这个阶段。我确信我很快就能让它工作了,但是我缺少了一些非常基本的东西 下面活动的代码片段Android ProgressBar不会出现,也不会显示任何进展,android,android-progressbar,Android,Android Progressbar,我已经试了一段时间了,看了几篇这样的帖子,就到了这个阶段。我确信我很快就能让它工作了,但是我缺少了一些非常基本的东西 下面活动的代码片段 public class SearchResultsMap extends MapActivity { .... public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeatu
public class SearchResultsMap extends MapActivity {
....
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setContentView(R.layout.searchresultsmap);
...
busy = (LinearLayout) findViewById(R.id.busy);
busy.bringToFront();
progressBar = (ProgressBar) findViewById(R.id.progressBar) ;
progressBar.bringToFront() ;
searchResponse = (HashMap<Integer, CustomJourneyUserInformation>) this.getIntent()
.getSerializableExtra("searchResponse");
new GetProviderAndUserDetails(this).execute(null);
>>edit1 progressBar.setMax(searchResponse.size());
>>edit1 progressBar.setProgress(0) ;
...
}
//Inner Class, type AsyncTask
public class GetProviderAndUserDetails extends AsyncTask<String, Integer, Object> {
public GetProviderAndUserDetails(Activity mapActivity) {
this.mapActivity = mapActivity;
}
protected void onPreExecute() {
busy.setVisibility(View.VISIBLE);
setProgressBarVisibility(true) ;
setProgressBarIndeterminate(true) ;
setProgressBarIndeterminateVisibility(true) ;
}
@Override
protected void onProgressUpdate(Integer... progress) {
if (searchActivity != null) {
searchActivity.setProgress(progress[0]);
>>edit1 progressBar.setProgress(progress[0]) ;
}
}
@Override
protected Object doInBackground(String... args) {
...
//for loop, i
publishProgress(i) ;
//end for loop
...
}
protected void onPostExecute(Object result) {
super.onPostExecute(result);
busy.setVisibility(View.GONE);
setProgressBarVisibility(false) ;
setProgressBarIndeterminate(false) ;
setProgressBarIndeterminateVisibility(false) ;
...
}
}
公共类SearchResultsMap扩展了MapActivity{
....
创建时的公共void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE\u不确定\u进度);
setContentView(R.layout.searchresultsmap);
...
busy=(LinearLayout)findviewbyd(R.id.busy);
忙碌的,忙碌的;
progressBar=(progressBar)findViewById(R.id.progressBar);
progressBar.bringToFront();
searchResponse=(HashMap)this.getIntent()
.getSerializableExtra(“searchResponse”);
新的GetProviderAndUserDetails(this).execute(null);
>>edit1 progressBar.setMax(searchResponse.size());
>>edit1 progressBar.setProgress(0);
...
}
//内部类,类型AsyncTask
公共类GetProviderAndUserDetails扩展异步任务{
public GetProviderAndUserDetails(活动映射活动){
this.mapActivity=mapActivity;
}
受保护的void onPreExecute(){
busy.setVisibility(View.VISIBLE);
setProgressBarVisibility(真);
setProgressBarIndeterminate(真);
SetProgressBarInDeterminateVibility(真);
}
@凌驾
受保护的void onProgressUpdate(整数…进度){
if(searchActivity!=null){
searchActivity.setProgress(progress[0]);
>>edit1 progressBar.setProgress(进度[0]);
}
}
@凌驾
受保护对象doInBackground(字符串…参数){
...
//对于循环,我
出版进度(一);
//循环结束
...
}
受保护的void onPostExecute(对象结果){
super.onPostExecute(结果);
busy.setVisibility(View.GONE);
设置可见性(假);
setProgressBarIndeterminate(假);
SetProgressBarInDeterminateVibility(假);
...
}
}
布局XML文件
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:id="@+id/busy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:gravity="center_horizontal"
android:orientation="vertical"
android:visibility="visible" >
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleLarge"
android:indeterminateOnly="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp" />
</LinearLayout>
.....
<com.google.android.maps.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/searchMap"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@id/tip"
android:layout_alignParentTop="true"
android:apiKey="mykey"
android:clickable="true" />
....
</RelativeLayout>
.....
....
设备结果:无法上载到stackoverflow。某些SO问题
您正在调用
setProgressBarIndeterminate()
和相关函数,这些函数作用于活动的标题,而不是布局中的进度条
改用progressBar.setUndeterminate()
和friends
编辑:如果您想要一个进度条而不是不确定的进度指示符,请使用
setIndeterminate(false)
调用的setprogressbarindereminate()
和相关函数,它们作用于活动的标题,而不是布局中的进度条
改用progressBar.setUndeterminate()
和friends
编辑:如果您想要一个进度条而不是不确定的进度指示器,请使用
setIndeterminate(false)
将xml中的样式设置为progressBarStyleHorizontal
。似乎progressBarStyleLarge
无法显示进度
不确定的事情也起到了作用。在xml中将样式设置为
progressBarStyleHorizontal
。似乎progressBarStyleLarge
无法显示进度
不确定的东西也有帮助。不,进度没有显示出来。它仍然是一件愚蠢的忙碌的事情。我不介意活动进度条显示出来,我只需要显示一些东西。活动进度条现在已经显示出来,而视图没有显示进度。这就是“设置不确定”的意思-“那个愚蠢的忙碌的东西”。如果你不想那样,用“false”代替“true”。酷,我不知道。我将它设置为false,它就会消失。编辑代码查找“>>edit1”“在活动课上谢谢,你的回答给了我必要的提示。不,进度没有显示出来。它仍然是一件愚蠢的忙碌的事情。我不介意即使活动进度条显示出来,我只需要显示一些东西。活动进度条现在已经显示出来了,而视图没有显示进度。这就是为什么。”“setUndeterminate”的意思是“那个愚蠢的忙碌的东西”。如果你不想这样,用“false”代替“true”。酷,我不知道。我把它设为false,它就消失了。编辑代码在活动类中查找“>>edit1”。谢谢,你的回答给了我必要的提示。