title: AlertDialog不顯示文字
date: 2017-06-27 10:33:27
tags: problems
- 問(wèn)題描述
在自己小米5S安卓6.0上測(cè)試,發(fā)現(xiàn)彈框只有按鈕沒(méi)有文字,title和message都不顯示,但是位置還是預(yù)留了的,很奇怪。
- 解決辦法:
AlertDialog.Builder builder;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
builder = new AlertDialog.Builder(mContext,R.style.Theme_AppCompat_Light_Dialog_Alert);
}else {
builder = new AlertDialog.Builder(mContext);
}
mDialog= builder.setTitle("需要開(kāi)啟一些權(quán)限")
.setMessage("因?yàn)榧尤肓苏Z(yǔ)音識(shí)別,所以需要獲取一些手機(jī)狀態(tài)、定位信息等權(quán)限,麻煩您通過(guò)一下")
.setPositiveButton(getString(R.string.confirm),this )
.setNegativeButton(getString(R.string.cancel),this)
.create();
5.0以上設(shè)置一個(gè)主題就行了.