I am trying to create an AlertDialog
but the buttons are not showing. Only seeing this issue in Android 7.0:
final AlertDialog.Builder builder =
So it turns out on Android 7.0 you have to provide a theme. At least, that's what I had to do.
<style name="AlertDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="borderlessButtonStyle">@style/Widget.AppCompat.Button.Borderless.Colored</item>
</style>
final AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity(), R.style.AlertDialogTheme);
Maybe its too late, but I hope someone would use this solution. you can do it something like this: You should set onShowListenter to your alertDialog, inside this function you should getButton() and than setTextColor to it. An example:
alertDialog = alertDialogBuilder.create();
alertDialog.setOnShowListener(new DialogInterface.OnShowListener(){
@Override
public void onShow(DialogInterface dialogInterface){
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(R.color.black);
}
});
I had a similar issue and the thing was that I wasn't using the support library for my AppCompatActivity, therefore I changed:
import android.app.AlertDialog;
to
import android.support.v7.app.AlertDialog;
and it worked.