之前一直再想按下触摸屏或者回退键,就会立马关闭进度条。但是,项目有需要,必须在进度条结束之后,才能按下回退键。
所以,就搜索了一下资料,最后实现如下:
[java] view plain copy
ProgressDialog pd;
/**
* 等待连接滚动条
*/
private void initProgDialog() {
// TODO Auto-generated method stub
flag=false;
pd=new ProgressDialog(this);
pd.setIndeterminate(false);
pd.setMessage("请等待");
pd.setCancelable(false);
pd.setProgressStyle(ProgressDialog.STYLE_SPINNER);
pd.show();
}
其实最关键的就是要设置:
[java] view plain copy
还有,如果你的是有实体搜索键的android机的话,就要加上如下代码:
[java] view plain copy
pd.setOnKeyListener(new DialogInterface.OnKeyListener() {
@Override
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
if(keyCode==event.KEYCODE_SEARCH){
return true;
}
else{
return false;
}
}
});
ps:实体搜索键就是event.KEYCODE_SEARCH
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有