SherlockFragmentActivity setSupportProgressBarIndeterminateVisibility不起作用

时间:2012-08-20 01:12:31

标签: android actionbarsherlock

我正在尝试在SherlockFragmentActivity中显示不确定的进度条 但我的代码只显示没有ProgreessBar的ActionBar

以下是我在Android 4.1.1中运行的代码

import com.actionbarsherlock.view.Window;
....
....
public class SowahActivity extends SherlockFragmentActivity{
....
...
...
protected void onCreate(Bundle savedInstanceState) {

        requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
        setSupportProgressBarIndeterminateVisibility(true);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.my_list_view);
}
...
...
}

是什么让进度对话框没有出现在操作栏

2 个答案:

答案 0 :(得分:5)

您正在尝试在创建Activity之前设置进度条。请尝试重新排序:

requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
super.onCreate(savedInstanceState);
setContentView(R.layout.my_list_view);
setSupportProgressBarIndeterminateVisibility(true);    

答案 1 :(得分:1)

 //This has to be called before setContentView and you must use the
        //class in com.actionbarsherlock.view and NOT android.view
        requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);