当我单击按钮时,它会等待 20 秒,然后将文本显示为文本视图,我的要求是 1 秒后,进度条必须增加 5 个值。任何人都可以指导我使用以下代码
public class ProgressBar1 extends Activity{
TextView tvpbview;
ProgressDialog pd1;
ProgressBar pbhr1;
Button btnhp1;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.progressbar1);
btnhp1 = (Button) findViewById(R.id.btnProgress);
pbhr1 = (ProgressBar) findViewById(R.id.pbHori1);
pbhr1.setMax(100);
btnhp1.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
//--- For Horizontal Progress Bar------
for(int i=0;i<=20;i++)
{
pbhr1.incrementProgressBy(5);
tvpbview.setText(""+pbhr1.getProgress()+"% done");
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
});