I am having a problem with a custom view in the android API API dialog box.
I use AlertDialog.Builder to create my dialog. I enable the custom view panel using the setView in the builder.
This works on most of the APIs I've tested with. The style changes somewhat from device to device, but this is what I want, since the style conforms to the device standard.
My problem is that on API 10, any text that is in my user view is displayed black on a black background.
Any text that I insert using AlertDialog.Builder.setMessage() is displayed correctly.
What magic attribute / style is a dialog box builder using to determine the appearance of text?
My theme is Theme.AppCompat.Light application.
Here is my onCreateDialog method:
public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater inflater = getActivity().getLayoutInflater(); final View view = inflater.inflate(R.layout.fragment_status_dialog, null); mStatusTextView = (TextView) view.findViewById(R.id.text_status); mConnectedDeviceTextView = (TextView) view.findViewById(R.id.text_connected_device); MainService.ServiceState state = null; if (getArguments().containsKey(SERVICE_STATUS_ARG_KEY)) { state = (MainService.ServiceState) getArguments().getSerializable(SERVICE_STATUS_ARG_KEY); } setState(state); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setView(view); builder.setMessage("This will show up just fine."); builder.setTitle(getString(R.string.status_title)); builder.setNegativeButton(R.string.dialog_back_button_text, null); builder.setNeutralButton(R.string.dialog_connect_to_text, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { mListener.onDialogConnectTo(); } });
Here is my layout_status_dialog layout
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" xmlns:android="http://schemas.android.com/apk/res/android" android:padding="18dp"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium" android:text="@string/status_starting" android:id="@+id/text_status"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium" android:text="@string/status_connected_to_unknown" android:paddingStart="4dp" android:paddingLeft="4dp" android:paddingRight="4dp" android:id="@+id/text_connected_device" android:layout_toRightOf="@+id/text_status" android:layout_toEndOf="@+id/text_status"/> </RelativeLayout>
Notice, I tried https://stackoverflow.com/a/31296916/2127321 , but it didn’t fix it.

source share