想实现这效果,但是我不知道把这Toast怎么处理才能在我的进度条对话框结束后显示出来。
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button but1=(Button)findViewById(R.id.but1);
but1.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
AlertDialog.Builder myDialog=new AlertDialog.Builder(MainActivity.this);
final View dialogView=LayoutInflater.from(MainActivity.this).inflate(R.layout.res,null);
myDialog.setTitle("登录界面");
myDialog.setView(dialogView);
myDialog.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
final int Max_PROGRESS=5;
final ProgressDialog waitingDialog=new ProgressDialog(MainActivity.this);
waitingDialog.setMessage("登录中....");
waitingDialog.setCancelable(false);
waitingDialog.setIndeterminate(true);
waitingDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
waitingDialog.show();
new Thread(new Runnable(){
@Override
public void run(){
int progress=0;
while(progress<Max_PROGRESS){
try{
Thread.sleep(1000);
progress++;
waitingDialog.incrementProgressBy(progress);
}catch(InterruptedException e){
e.printStackTrace();
}
waitingDialog.cancel();
}
}
}).start();
}
});
myDialog.show();
}
});
}