1

My app has a Preference Screen that looks like this:

Current preference screen

But I need to create a new interface that look more like this:

Preference screen desired

So a kind of button using on/off interface.

Is there somehow a way to convert, by editing the code, the previous interface to the new one (for example to change the SwitchPreferences to Buttons and align them in the PreferenceScreen as shown in the 2nd image) or is it not possible and I should start from scratch?

TheOldBlackbeard
  • 395
  • 4
  • 22
  • There is not any way I know till that automatically things get turned into required screen. I guess we have to design it. Start from the scratch mate! – Vir Rajpurohit Jul 08 '19 at 14:27

1 Answers1

2

There is no automated tool that can be used for conversion of a screen to another screen. The best bet would be to reuse code but start with a new activity layout and implement the old code into the new format.

To best achieve the look of the second image, I would recommend using a custom horizontal LinearLayout paired with a vertical LinearLayout, this way you can have a grid (e.g. 4 by 2)

wareisjared
  • 330
  • 1
  • 2
  • 17
  • Yeah, I did not mean to use an automated tool, but edit the code, so to preserve the functionalities (or in any case keep more previous code possible) but changing the design. So would it be better for me to keep the PreferenceScreen interface and do something like that (Nicolas answer: https://stackoverflow.com/questions/5298370/how-to-add-a-button-to-a-preferencescreen)? even if in this case I don't know how to combine with the 3x2 layout. Or is better directly use a LinearLayout interface (therefore no longer a PreferenceScreen) and so change almost completely the code? – TheOldBlackbeard Jul 08 '19 at 15:11
  • 1
    I would recommend keeping the layout file but changing it's contents to fit your new needs, then inside the main layout you can implement the grid. @TheOldBlackbeard – wareisjared Jul 08 '19 at 15:19
  • Theoretically you _could_ make this still using a PreferenceScreen, but you'd have to change so many things to get this to work - anything that isn't a list of items is not natively supported. I would strongly recommend just building it yourself, since this is very very different. – Louis Jul 12 '19 at 00:22
  • I agree with @Louis, there will be some code overlap but a fresh new activity would be easier to avoid bugs and unneeded code etc. If worse comes to worse your old version code should be easily reachable in a backup. – wareisjared Jul 12 '19 at 08:16