简单的使用ProgressBar控件,同时使用AsyncTask来更新ProgressBar的进度。
界面的代码在这里就不放出来。
主要看一下MainActivity.java和ProgressBarAsyncTask.java这两个类
package cn.qing.ui;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.RatingBar;
import android.widget.TextView;
public class MainActivity extends Activity {
private ProgressBar pbar1,pbar2,pbar3,pbar4;
private Button but1,but2,but3,but4,but5,but6;
private RatingBar ratingbar;
private TextView textView;
private int progress;
private boolean toggle = true;
private float rating;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
init_view();
}
private void init_view() {
pbar1 = (ProgressBar) this.findViewById(R.id.progressBar1);
pbar2 = (ProgressBar) this.findViewById(R.id.progressBar2);
pbar3 = (ProgressBar) this.findViewById(R.id.progressBar3);
pbar4 = (ProgressBar) this.findViewById(R.id.progressBar4);
progress = pbar3.getProgress();
ratingbar = (RatingBar) this.findViewById(R.id.ratingBar1);
rating = ratingbar.getRating();
textView = (T