Is there any way of setting the layoutResId of android.preference.Preference? I need to replace com.android.internal.R.layout.preference with something more than a ListView. (I want a PreferenceActivity in another view, and for it to inflate the hierarchy of preferences in that view instead of only showing the default ListView). Through PreferenceActivity I can get the PreferenceManager, but PreferenceManager.getPreferenceScreen is package-private. PreferenceScreen.setLayoutResId can change the ResId I want, but I can't get at it. If I could, would changing this work or would it break things?
Asked
Active
Viewed 1,141 times
1
-
http://stackoverflow.com/questions/5334194/custom-preferencescreen-with-clickable-buttons – Sergey Benner Jan 27 '12 at 15:15
1 Answers
1
You can call setContentView
on a PreferenceActivity
as long as there is a ListView
somewhere in the layout with an ID of android.R.id.list
(or @android:id/list
from XML). This will be the target into which preferences are inflated. You are free to add whatever other views you'd like as long as this requirement is met.

Jake Wharton
- 75,598
- 23
- 223
- 230