How do you change the textcolor of the list items in an AlertDialog
Asked Answered
M

2

6

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!

Moskva answered 3/12, 2010 at 7:18 Comment(3)
any idea what is the style for the ListPreference to use ? i can tell you i had the same issue with dialogs (background) and i found there is a C'tor that includes a theme as int for me to use so i could inherit from the original Dialog.Theme and change my own properties.Profiteer
No, that is essentially my question, which style do I need to override in order to change the text color in the ListView for an AlertDialogMoskva
Since your question has to do with ListPreference and I have never done anything with that... I am not sure that this will help you... however, in reference to a ListView in an AlertDialog, I can help you with that. anddev.org/code-snippets-for-android-f33/…Maxfield
M
1

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.

Minda answered 7/12, 2010 at 21:42 Comment(7)
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 :DMoskva
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
R
-1

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);
Rumal answered 3/12, 2010 at 8:49 Comment(1)
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.