Android 用AsyncTask进行异步开发(2)

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;

public class MainActivity extends Activity {
 private Button button;
 private ProgressBar progressBar;
 private TextView textView;
 
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       
        button = (Button)findViewById(R.id.button03);
        progressBar = (ProgressBar)findViewById(R.id.progressBar02);
        textView = (TextView)findViewById(R.id.textView01);
       
        button.setOnClickListener(new OnClickListener() {
   
   @Override
   public void onClick(View v) {
    ProgressBarAsyncTask asyncTask = new ProgressBarAsyncTask(textView, progressBar);
    asyncTask.execute(1000);
   }
  });
    }
}

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/63cca7627050094fdb65164064f3eef0.html