在我的應用程序主題colorPrimary是白色的。因此,alertdialog的textcolor在Android N下面不可見。然後,我爲alertdialog創建了一個自定義主題,但仍然無法正常工作。當colorprimary是白色時不顯示警報對話框文本
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@android:color/transparent</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="windowActionModeOverlay">true</item>
<item name="android:windowLightStatusBar">true</item>
<item name="android:windowAnimationStyle">@style/CustomActivityAnimation</item>
</style>
這是我的自定義提醒對話框主題。我的對話框有arrayadapter。
<style name="AlertDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="android:textColor">#000000</item>
<item name="android:textColorPrimary">#000000</item>
</style>
我用下面的代碼這個主題。
private void showAccountSettingsPopUp(){
AlertDialog.Builder builder;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
builder = new AlertDialog.Builder(this);
} else {
builder = new AlertDialog.Builder(this, R.style.AlertDialogTheme);
}
List<String> stringList = new ArrayList<>();
stringList.add(getString(R.string.blocked_list));
stringList.add(getString(R.string.edit_my_profile));
stringList.add(getString(R.string.delece_acc));
ArrayAdapter<String> adapter = new ArrayAdapter<>(getApplicationContext(), android.R.layout.simple_list_item_1, stringList);
builder.setAdapter(adapter, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
switch (i){
case 0:
startActivity(new Intent(SettingsActivity.this, BlockedUserActivity.class));
break;
case 1:
startActivity(new Intent(SettingsActivity.this, EditProfilActivity.class));
break;
case 2:
showTwoButtonAlert(getString(R.string.are_you_sure), getString(R.string.delete_acc_text), false);
break;
}
}
});
builder.show();
}
這是行不通的。還是一樣的結果。我找到解決方案。 – abalta