requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
再調用 setProgressBarIndeterminateVisibility(true/false) 方法來顯示/隱藏它.
實例:
package com.AndroidProgressTitleBar;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;
public class AndroidProgressTitleBarActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setContentView(R.layout.main);
Button btnTurnOnProgress = (Button)findViewById(R.id.progresson);
Button btnTurnOffProgress = (Button)findViewById(R.id.progressoff);
btnTurnOnProgress.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
setProgressBarIndeterminateVisibility(true);
}});
btnTurnOffProgress.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
setProgressBarIndeterminateVisibility(false);
}});
}
}
沒有留言:
發佈留言