您好我想先显示加载或进度对话1秒,然后按钮执行其他操作....请帮助
button1 = (Button) findViewById(R.id.button1);
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
<!-- want to a Show a Loading or Progress Dailog for 1 Second -->
if (isInternetPresent) {
// Internet Connection is Present
} else {
// Internet connection is not present
InternetNotContectedAlert();
}
答案 0 :(得分:2)
就这样做,它会起作用。
ProgressDialog csprogress=new ProgressDialog(NextActivity.this);
Button csButton=(Button)findViewById(R.id.txtx);
csButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
csprogress.setMessage("Loading...");
csprogress.show();
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
csprogress.dismiss();
//whatever you want just you have to launch overhere.
}
}, 1000);//just mention the time when you want to launch your action
}
});