gpt4 book ai didi

android - 调用需要 API 级别 11(当前最小值为 8): new android. app.AlertDialog.Builder

转载 作者:行者123 更新时间:2023-11-30 02:27:08 27 4
gpt4 key购买 nike

我在做什么:

  • 我正在 Activity 中使用它
  • 我的 Activity 扩展了 ActionBarActivity
  • list 中我的最小 sdk 是 8

我得到的错误是:

Call requires API level 11 (current min is 8): new android.app.AlertDialog.Builder

代码

public void openSettings(String custMsg){

final AlertDialog.Builder alert = new AlertDialog.Builder(this,AlertDialog.THEME_DEVICE_DEFAULT_DARK);
alert.setMessage(custMsg);
alert.setCancelable(false);
alert.setNegativeButton(getResources().getString(R.string.Cancel), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
dialog.dismiss();
tryAgainId.setVisibility(View.VISIBLE);
}
});
alert.setPositiveButton(getResources().getString(R.string.Ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
locationValidationDone=true;
dialog.dismiss();
startActivity(new Intent(Settings.ACTION_SETTINGS));
}
});

alert.show();
}

问题:

我该如何解决

最佳答案

请看docs :

您使用的构造函数需要 API 11。

public AlertDialog.Builder (Context context, int theme)

Added in API level 11
Constructor using a context and theme for this builder and the AlertDialog it creates. The actual theme that an AlertDialog uses is a private implementation, however you can here supply either the name of an attribute in the theme from which to get the dialog's style (such as alertDialogTheme or one of the constants AlertDialog.THEME_TRADITIONAL, AlertDialog.THEME_HOLO_DARK, or AlertDialog.THEME_HOLO_LIGHT.

需要使用API​​ 1中添加的构造器:

public AlertDialog.Builder (Context context)

Added in API level 1
Constructor using a context for this builder and the AlertDialog it creates.

关于android - 调用需要 API 级别 11(当前最小值为 8): new android. app.AlertDialog.Builder,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27801884/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com