Hello I am trying to change the text color of the items in a list on a ListPreference
pop up window. I have spent over an hour looking through all of the various style names but I can't find TextAppearance
or anything that goes to this particular text. Thanks for your help!
How do you change the textcolor of the list items in an AlertDialog
Asked Answered
You can't and you shouldn't. *Preference
uses styles from com.android.internal.R.styleable
which might be changed by manufactures. The idea of using the default ones is that every preference screen in your device look alike.
On the other hand you can try doing an Activity
with android:theme="@android:style/Theme.Dialog"
in your app's AndroidManifest
and place a ListView
styled as you want.
I haven't applied the theme to the Preference itself but the AlertDialog. Theme looks great on all other AlertDialogs but the unfortunate side effect is
ListPreference
also uses an AlertDialog
so I have my dark background now and the text is un-readable. I can make a special case style for my PreferenceActivity
that doesn't override the AlertDialog
theme but it would be nice if it could match the rest of the app.. –
Moskva If you are changing the theme, just create a new activity with Theme.Dialog style and do whatever you want in it. –
Minda
Preference.DialogPreference is the style of the parent of ListPreference, there doesn't sceem to be a direct style of the ListPreference. You can override that specific style in the theme and apply it to all activites, this wat you don't affect all AlertDialogs. –
Profiteer
@Minda The
ListPreference
isn't going to use my Theme.Dialog @Profiteer thanks I'll look into that, you may need to throw that into an answer if it works :D –
Moskva I never ment to use Theme.Dialog in a
ListPreference
. I tried to explain how to make a new activity using Theme.Dialog and making it look like a ListPreference. –
Minda Won't work this is the list preference in a preference activity with a bunch of other preferences as well. –
Moskva
Why? You can open activities from a preferenceActivity. –
Minda
I don't really know which kind of View
use ListPreference
, probably it's something like TextView
. If so than you could make smth like:
TextView textView;
String myString;
//....
SpannableString spanString=new SpannableString(myString);
spanString.setSpan(new ForegroundColorSpan(Color.RED), 0, myString.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
textView.setText(spanString);
no this isn't the answer, first off how would you even get a reference to the
TextView
I am looking for a way to fix this through styles. Thanks. –
Moskva © 2022 - 2024 — McMap. All rights reserved.
ListView
for anAlertDialog
– Moskva