[英]Android - Alert Dialog force close
我想在下面显示警报对话框,但是它强制关闭,我对上下文应该是什么感到有些困惑。 单击图像时将显示此对话框。
AlertDialog.Builder builder = new AlertDialog.Builder(
getApplicationContext(), R.style.TitleDialog);
builder.setTitle("Sorry for Inconvinience");
builder.setMessage("You need to install MX Player or VLC Media Player");
AlertDialog alert = builder.create();
alert.show();
我是一个初学者,对您的任何帮助将不胜感激。
ib2.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (isInternetPresent) {
try {
startActivity(i2);
} catch (Exception e) {
AlertDialog.Builder builder = new AlertDialog.Builder(Main.this);
builder.setTitle("Sorry for Inconvinience");
builder.setMessage("You need to install MX Player or VLC Media Player, here is the link: ");
AlertDialog alert = builder.create();
alert.show();
}
} else {
Toast.makeText(getApplicationContext(),
"Please check your Internet Connection.",
Toast.LENGTH_LONG).show();
}
}
});
AlertDialog.Builder builder = new AlertDialog.Builder(Activity.this);
builder.setTitle("Sorry for Inconvinience");
buildersetMessage("You need to install MX Player or VLC Media Player");
.show();
上面的代码应该工作。 我也不知道
getApplicationContext(), R.style.TitleDialog);
用于。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.