Memory friendly : View in xml or java class?

可紊 提交于 2019-12-24 10:24:19

问题


I am starting with development in android apoplications, but not sure about the creation of views. Which one of the two is more preferable in terms of memory-consumption for creation of views : XML or Java Class ?

Can you please suggest which approach is more memory-friendly either XML or Java classes for creation of view ?


回答1:


There is ultimately Java behind the xml..

so both are same as creating from Java or using xml.

XML help us to customize Views quickly and drag & drop graphically.

The Layout tricks actually works. (For example: Here is an illustration to optimize the memory consumption.)




回答2:


If you are just starting with the development and you are new to android..go with XML its easier to understand and experiment with.there are a lot of tutorials around.

Java classes are usually used to set view dynamically..so i would suggest start with XML and move to simple Java tutorials. with memory friendly part(i dint get what you are trying to say) if its about the load time or the CPU usage.its non the less same.




回答3:


For the purpose of memory-consumption XML Views are best to use but if you want to make your View Dynamic as you receive data from the Server or from any other resource at run time Then you can use Java for creating those Views.



来源:https://stackoverflow.com/questions/8876097/memory-friendly-view-in-xml-or-java-class

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!