Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change PreferenceCategory android:title

I was wondering if there was a way to change the

PreferenceCategory android:title="my name"

programmatically and or the

ListPreference android:title="my name"

programmatically.

like image 913
Keith Avatar asked Sep 03 '11 21:09

Keith


1 Answers

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.

like image 111
Patrick Avatar answered Oct 01 '22 15:10

Patrick