主界面 Acitivity
- public class ThreadDownloadDemo extends Activity { private TextView downloadurl;
- private EditText downloadnum; private Button downloadbutton;
- private ProgressBar downloadProgressBar; private TextView downloadinfo;
- private int downloadedSize = 0; private int fileSize = 0;
- private long downloadtime; @Override
- public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
- setContentView(R.layout.threaddemo); downloadurl = (TextView) findViewById(R.id.downloadurl);
- downloadurl.setText("http://www.easck.com/201105110911/AA5CC27CBE34DEB50A194581D1300881/Special_323149/%E8%8D%B7%E5%A1%98%E6%9C%88%E8%89%B2.mp3"); downloadnum = (EditText) findViewById(R.id.downloadnum);
- downloadinfo = (TextView) findViewById(R.id.downloadinfo); downloadbutton = (Button) findViewById(R.id.downloadbutton);
- downloadProgressBar = (ProgressBar) findViewById(R.id.downloadProgressBar); downloadProgressBar.setVisibility(View.VISIBLE);
- downloadProgressBar.setMax(100); downloadProgressBar.setProgress(0);
- downloadbutton.setOnClickListener(new OnClickListener() { public void onClick(View v) {
- download(); downloadtime = SystemClock.currentThreadTimeMillis();










