Thursday, April 11, 2013

[android help] Can all xml layout convert to java code in Android?

Can all xml layout convert to java code in Android? - Stack Overflow



















After developing few applications, I know that many people like to add view programmatic ally.
But is it all xml layout can convert to java code dynamically?
What is the pros and cons of using java code to generate the layout?


























The layout XML you are creating is being translated at run-time to java code. So the answer to your question is Yes. You can do the same and basically create all your layout in java code from scratch.


The obvious down grade of this thehnic as you know is that it will take you much more time to achieve the same result as with the XML file.
























But is it all xml layout can convert to java code dynamically?



Yes



What is the pros and cons of using java code to generate the layout?



According to the documentation the advantage to declaring your UI in XML is that it enables you to better separate the presentation of your application from the code that controls its behavior. Your UI descriptions are external to your application code, which means that you can modify or adapt it without having to modify your source code and recompile. For example, you can create XML layouts for different screen orientations, different device screen sizes, and different languages. Additionally, declaring the layout in XML makes it easier to visualize the structure of your UI, so it's easier to debug problems.


Please read this link for more details




















default






.

stackoverflow.comm

No comments:

Post a Comment

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...