1

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?

Charles
  • 50,943
  • 13
  • 104
  • 142
jamesd
  • 11
  • 2

1 Answers1

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