nipun
nipun

Reputation: 103

Dynamically change the content/layout/flow controlled via server

I am new to android development, and we have a very specific requirement. We need to change the content/layout/flow of the app on the fly. For e.g. we have a layout which consists of some images, textarea and textboxes. There might be a request coming to change the textarea to a textbox.

We thought about this and are thinking to provide the apk with a json/xml which will contain all these changes.

My question is will it be possible to re-draw the objects again dynamically and change the content?

Upvotes: 0

Views: 1800

Answers (2)

When you design a Android Application with Activities and Fragments your XML layout definition is always static. If you want a true dynamic layout structure you should use a Web View with a HTML content pointing some URL.

As Rahul says, another approach is to manage the "default cases". For me that is the standard way to design an Android Application.

The dynamic content (values) can be done with a simple http call to server you can get values for your views.

The navigation could be handled by switching Intents, but, definitively you have to associate these intents to UI elements like buttons in the most cases, and ¿How you can do that if your layout is changing over time?.

I think, that the WebView could be a very easy solution for your problem.

Upvotes: 0

Rahul Sundar
Rahul Sundar

Reputation: 490

Yes this is possible. You can dynamically design what has to be displayed in your Activity UI screen. If you feel there are only 2 or 3 different UI screens that would be repeatedly used, then you can have XMLs for these screens and you can just change their labels in OnCreate() of Activity class before rendering. LayoutInflater class would be helpful here.

Upvotes: 1

Related Questions