Skip to content
This repository has been archived by the owner on Mar 19, 2022. It is now read-only.

Foreground color disappears when I add to an AlertDialog. #37

Open
brightak opened this issue May 20, 2021 · 0 comments
Open

Foreground color disappears when I add to an AlertDialog. #37

brightak opened this issue May 20, 2021 · 0 comments

Comments

@brightak
Copy link

Hello,

When I put the datepicker in an AlertDialog, the forecolor disappears, as follows:

Set Body Weight

Here's some code:
`

    btn.setOnClickListener(v -> {

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

        LayoutInflater inflater1 = getLayoutInflater();
        View dlgWeights = inflater1.inflate(R.layout.weights_dialog,null);

        builder.setTitle("Set Body Weight");

        builder.setView(dlgWeights);

        tvWeights = dlgWeights.findViewById(R.id.tvWeights);

        tvWeights.setText(spnWeights.getSelectedItemPosition() == 0 ? getString(R.string.lbs) : getString(R.string.kilos));

        npWeight = dlgWeights.findViewById(R.id.npWeight);

        Log.i("ProfileDialog", "Launching DatePickerTimeline");
        final DatePickerTimeline timeline = dlgWeights.findViewById(R.id.datePickerTimeLine);

        final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

        timeline.setOnDateSelectedListener((year, month, day, index) -> {
            Calendar date = Calendar.getInstance();
            date.set(year, month, day);
            refreshWeight(sdf.format(date.getTime()));
        });

        Calendar current = Calendar.getInstance();

        timeline.setSelectedDate(current.get(Calendar.YEAR), current.get(Calendar.MONTH), current.get(Calendar.DATE));

        refreshWeight(sdf.format(current.getTime()));

        builder.setPositiveButton(getString(R.string.OK), (dialog, which) -> {
            Calendar d = Calendar.getInstance();
            d.set(timeline.getSelectedYear(), timeline.getSelectedMonth(), timeline.getSelectedDay(), 0, 0, 0);
            ((ExerciseActivity) getActivity()).exerciseViewModel.ensureWeight(npWeight.getValue(), (int) (d.getTimeInMillis() / 1000L));
            refreshBodyWeight();
            dialog.dismiss();
        });

        builder.setNegativeButton(getString(R.string.Cancel), (dialog, which) -> dialog.dismiss());

        final AlertDialog dialog = builder.create();

        dialog.show();

    });`

R.layout.weights_dialog:

`

<com.github.badoualy.datepicker.DatePickerTimeline
    android:id="@+id/datePickerTimeLine"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"/>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="15dp"
    android:orientation="horizontal">

    <TextView
        android:id="@+id/tvWeights"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="TextView" />

    <com.michaelmuenzer.android.scrollablennumberpicker.ScrollableNumberPicker
        android:id="@+id/npWeight"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:orientation="horizontal"
        app:snp_scrollEnabled="true"
        app:snp_updateInterval="5" />

</LinearLayout>
`

Thanks in advance for any assistance.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant