Answer the question
In order to leave comments, you need to log in
AlertDialog is deprecated?
I want to create a simple dialog box. Decided to do it with alertDialog. Created a method in the recyclerView element adapter class, set the image, title, main message. But the trouble is, the color of the main text does not change from white, no matter how I try. I created a separate style, tried to color it using HTML in the code - alas, nothing helped, the text remained the same.
So, is it worth creating a custom dialog or am I doing something wrong. Personally, I did not find anything in the documentation related to the elimination, but maybe.
Dialog class
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import androidx.fragment.app.DialogFragment;
public class DeleteDialog extends DialogFragment {
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder adb = new AlertDialog.Builder(getActivity(), R.style.df)
.setIcon(R.drawable.icon_basket)
.setTitle("Title!").setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
}
})
.setNegativeButton("cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
}
})
.setMessage("R.string.message_text");
return adb.create();
}
public void createDialog() {
deleteDialog = new DeleteDialog();
deleteDialog.show(fragmentManager, "q");
}
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="theme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
<item name="android:windowFullscreen">true</item>
<item name="colorPrimary">@color/colorC</item>
<item name="colorPrimaryDark">@color/colorD</item>
<item name="colorAccent">@color/colorC</item>
<item name="android:listDivider">@color/colorGrayDivider</item>
<item name="android:textColor">@color/colorGray</item>
<item name="android:popupBackground">@color/colorWhite</item>
<item name="fontFamily">@font/giger</item>
</style>
<style name="splashScreen" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@drawable/splash</item>
</style>
<style name="df" parent="ThemeOverlay.AppCompat.Dialog.Alert">
<item name="android:textColor">@color/colorGray</item>
</style>
</resources>
<item name="theme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question