tripleblep
tripleblep

Reputation: 540

Laying out controls

I'm trying to figure out the best course of action when it comes to drawing various control configurations. In my case, I'm using images as buttons and would like to create "screens" for different control configurations. Below is an example:

enter image description here

Basically, I'd have a layout for each configuration. Depending on which configuration the user requests, different control layouts will be used. There's only ever one configuration set loaded at any given time.

What's the general direction I should take for this? Should I just use Fragments for each configuration? I imagine I'd want to use a layout for each control configuration. Controls are required to be precise, so perhaps this library, in conjunction with layouts, will work for my needs?

Upvotes: 0

Views: 30

Answers (1)

Gumbo
Gumbo

Reputation: 1746

I would save the requested layout in SharedPreferences and in the onCreate() method get the layout id like this:

SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences();
int requestedLayout = prefs.getInt("requestedLayout", R.id.layout_default);
setContentView(requestedLayout);

Note: this only works if all layouts contain the same views, otherwise fragments will be better for this purpose.

Upvotes: 1

Related Questions