Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why we use xml?

We are creating many XML files for a single app in developing android applications; of course it's the main theme of android. For every screen of app we are creating an XML with some layouts (static implementation). In execution, every time XML file will be read to get all the resources that it wants to display the screen which we designed.

The same design can be achieved by adding few lines in the java code itself (dynamic implementation). Like we can extend ListActivity instead of creating XML file, for example. Then why to go for XML as the application need to read a file from phone memory which may leads to slow access and makes application slow?

So, dynamic implementation is always better than static one.

Please correct me if I am wrong.

like image 292
Aswin Avatar asked Jun 28 '12 16:06

Aswin


2 Answers

It helps organize and visualize the layouts very nicely. It provides a backbone to the gui that allows multiple devices to be supported by much less code.

like image 158
Jack Satriano Avatar answered Oct 13 '22 08:10

Jack Satriano


XML files are strongly encouraged because it makes your app more closely follow the Model-View-Controller programming strategy. Having each part as separate from each other as possible makes it easier to develop and maintain your overall program. The performance difference seems to be minimal, although others have said that XML is preprocessed.

like image 42
telkins Avatar answered Oct 13 '22 10:10

telkins