[英]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.