-2

I'm beginner in android , now I'm building an android application. .

I'm working in setting screen now and in my research i have seen so many applications that is using preference activity for the settings.So i started my setting page using preference activity. But in my case , my application settings have some options that don't need to save as preference. And that are also connecting with server and the EditTextPreference dialog will be also different. So i got confused in this case.

So what should i do? Do i have to change this to a LinearLayout?

Please help

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
bepositive
  • 65
  • 2
  • 6

2 Answers2

0

The preference compat fragment and activity is there to make it simple to create an interface and save it to SharePreference. but you can't change much of the thing. I believe the sharepreference compat and component is itself has the listener when is changing. So let it save to preference even if you don't need it probably Ok. Also if your mockup or design for EditTextPreference is look different from native android then You can try use theme and style to change the look and feel of EditText just for preference only.

Also, You probably can use scrollview + constrainlayout or linearlayout to build it but you're make extra work such as save/load to/from preference, UI like sub preference ...etc. I would sugguest to go with Theme and Style but if your UI is completely different and can't be adapted with Preference then it left no choice. Constraint Layout would be better than LinearLayout.

vsatkh
  • 179
  • 2
  • 10
  • Thank you so much for your answer..Yes i need the look and feel of preference activity that's why i have chosen this..but the saving of all things as preference has confused me..I doubted this way is wrong or not. – bepositive Apr 20 '17 at 14:08
  • It depend on what your needed. Normally, preference setting mean you edit or change and save it for later use. Setting like sound, vibration which might be use for user's favor which you needed at the certain time without backend and all stuff that save could also sync to the backend for cross device purpose. If you really don't need those as offline access then you can ignore preference. I have post gist on github for style and theme overrided https://gist.github.com/cmidt-veasna/26c8f1a2017ecc820f2565d0c8cb1e11. – vsatkh Apr 20 '17 at 16:27
0

The PreferenceFragment attached to a preference activity is the ideal way to have a settings screen. You will however need to implement the PreferenceChangeListener in the PreferenceFragment to listen for preference changes and save the changes. If you have options that do not need to be saved you can still add them to the xml and make them disabled by setting android:enabled = false.

EditTextPreferences can have their own UI feel by using the android:theme = @style/yourstyle and specifying the style you want in your styles.xml file

Goodluck.

Alfred Afutu
  • 191
  • 3