今天做掌上武大校园网启停的确认对话框,遇到了在android 6.0 机子上AlertDiog的title和message文字不显示的问题,如下图
看到网上的解决方案是导android.support.v7.app这个包,用这个包中的alertdialog,然而还是没有解决。
最后的解决方案是:
将AlertDialog对象创建换一种方式:
AlertDialog.Builder ab;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
ab = new AlertDialog.Builder(NetManagerActivity.this, android.R.style.Theme_Material_Light_Dialog_Alert);
} else {
ab = new AlertDialog.Builder(NetManagerActivity.this);
}
导入普通包即可解决:
import android.app.AlertDialog;