开发者

Android - Is it possible to change a property specifically for each ListPreference entry?

开发者 https://www.devze.com 2023-03-16 18:48 出处:网络
I have an ordinary Android ListPreference defined in my code - <ListPreference android:title=\"Font\"

I have an ordinary Android ListPreference defined in my code -

<ListPreference
        android:title="Font"
        android:summary="Choose the font of the reader"
        android:key="fontList"
        android:entries="@array/fonts"
        android:entryValues="@array/fontValues">

    </ListPreference>

It gives a list of a couple of different font types that the user can pick from, nothing special. What I wondering is, is there a way to set each list item's font to the font that it displays? This would be a nice feature as it would allow the user to see what 开发者_如何学运维they have to pick from before having to test it out.

I can't see any obvious way of doing it, or at least a way that wouldn't destroy the nice default UI.

Any help would be appreciated.


The best way to do it would be to extend the ListPreference class and implement your own preference. From memory I think you need to override the onCreateDialogView, onBindDialogView, onSetInitialValue and onDialogClosed methods. Best place to look is at the List Preference page on developer.android.com


like he said for fonts u will need custom one. But what I found that there are alot of different default android:theme="@android:style/Theme....." try the once that are available ... there are 9-10 of them. maybe u will get somewhat closer to what u need that extending your own custom UI.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号