2

Is there an easy way to create a preference like the system preferences in Lollipop?

My previous app had headers and fragments, but I want to use the AppCompat Toolbar and the PreferenceActivity (onBuildHeaders) can't use the new Toolbar. That's why I'm searching for a complete redesign of my preferences.

I want to do this:

enter image description here

Has someone any tutorial for this?

mars3142
  • 2,501
  • 4
  • 28
  • 58

2 Answers2

1

It' s simple. Just apply the Theme.AppCompat.xxx to your activity and put your PreferenceFragment in that activity if you use the Api level >= 11.

EDIT

for the lastest supoort libary appcompat-v7, google provides AppCompatDelegate to do the trick, here is the sample code from google.

longkai
  • 3,598
  • 3
  • 22
  • 24
  • And how about headers? Everyone is talking about PreferenceFragments, but I need header xml files. This file can't be used in a Fragment. The header file was used to do the two pane view. – mars3142 Nov 19 '14 at 16:23
  • well, forgive my carefulness when reading your question, I thought you just need that toolbar... take a look at this, i suppose it' s helpful. http://stackoverflow.com/questions/26564400/creating-a-preference-screen-with-support-v21-toolbar/26564401#26564401 – longkai Nov 19 '14 at 19:12
0

Try out my library: https://github.com/AndroidDeveloperLB/MaterialPreferenceLibrary .

It lacks some of the stuff of the original API, but it's a good start... The hard part is to make it use a RecyclerView instead of a ListView, so that you could have multiple preferences on the same row. Then you'd need to also filter items as you type.

android developer
  • 114,585
  • 152
  • 739
  • 1,270