0

I don't know which code to post, so I just post the Code of DialogFragment:

public class dialog_ChangeActivity extends AppCompatDialogFragment {
private static final String TAG = "dialog_ChangeActivity";

private ArrayList<obj_Activity> activityList;
private Spinner sp_DialogChangeActivity;

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    createArray();
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View view = inflater.inflate(R.layout.dialog_changeactivity, null);
    
    builder.setView(view)
            .setTitle("Change Activity");
    
    builder.setNegativeButton("Cancle", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
        
        }
    });
    
    builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
        
        }
    });
    
    sp_DialogChangeActivity = view.findViewById(R.id.sp_DialogChangeActivity);
    adapter_Spinner_ChangeActivity ac = new adapter_Spinner_ChangeActivity(getContext(), activityList);
    sp_DialogChangeActivity.setAdapter(ac);
    return builder.create();
}

Everthing works fine, but the buttons "Ok" and "Cancel" are invisible, I don't know why...

This ist what it looks like if I click

Update 1

I tried:

<item name="android:alertDialogTheme">@style/AlertDialogTheme</item>

<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>

with

AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.AlertDialogTheme);

Also I Changed the libary to import android.support.v7.app.AlertDialog;

Update 2

Okay, now I changed my styles.xml, to set the colort of the Text on the buttons manualy, but this gives me the buttons in default color, I don't know about that.

<style name="AlertDialogTheme" parent="Theme.AppCompat.Dialog.Alert">
        <item name="android:background">@color/Mercedes_WHITE</item>
        <item name="android:textColor">@color/Mercedes_BLACK</item>
        <item name="buttonStyle">@style/AlertButton</item>
        <item name="borderlessButtonStyle">@style/Widget.AppCompat.Button.Borderless.Colored</item>
    </style>

    <style name="AlertButton">
        <item name="android:textColor">@color/Mercedes_BLACK</item>
    </style>

Why did this happen?

Community
  • 1
  • 1
  • Possible duplicate of [Missing buttons on AlertDialog | Android 7.0 (Nexus 5x)](https://stackoverflow.com/questions/39621606/missing-buttons-on-alertdialog-android-7-0-nexus-5x) – sohel.eco Jul 26 '19 at 09:56
  • @sohel.eco, but the solutions there don't work for me – HydroHeiperGen Jul 26 '19 at 11:09

0 Answers0