I have a PreferenceActivity which has a custom preference. In the
onCreate() method I set a layout resource for the custom preference
like this:
Preference pref = (Preference) findPreference("customPref");
pref.setLayoutResource(R.layout.custompreflayout);
I then want to dynamically set the text of a TextView inside that
custompreflayout so I write the following:
TextView tv = (TextView)findViewById(R.id.tvTitle);
tv.setText("Some text");
However findViewById return null. At the beginning of the code I do
set a resource the following way:
addPreferencesFromResource(R.xml.preferences);
I don't know what to do to be able to set the TextView dynamically on
startup. I've tried moving the code to onStart(), onPostCreate and
others without success. I've also tried inflating it like this without
success:
LayoutInflater inflater = this.getLayoutInflater();
View v= inflater.inflate(R.layout.custompreflayout, null);
TextView tv = (TextView)v.findViewById(R.id.tvTitle);
Any ideas what to do?
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en