开发者

Change PreferenceCategory android:title

开发者 https://www.devze.com 2023-04-02 10:50 出处:网络
I was wondering if there was a way to change the PreferenceCategory android:title=\"my name\" programmatically and or the

I was wondering if there was a way to change the

PreferenceCategory android:title="my name"

programmatically and or the

ListPrefe开发者_如何学编程rence android:title="my name"

programmatically.


Keith,

Yes, there is a way to change the title programmatically. You must add a android:key="myTag" in your xml layout for the PreferenceCategory. Then you can access the PreferenceCategory from code by using findPreference("myTag"). The code is below:

XML:

<PreferenceCategory android:title="My Preferences"
   android:key="myPreferencesTitle" 
>

Java code:

PreferenceCategory prefCat=(PreferenceCategory)findPreference("myPreferencesTitle");
prefCat.setTitle("My New Title");

Hope this helps.

0

精彩评论

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