Which is more preferable or standard approach to display the UI for activity in Android Application Development either a Java Class or XML layout ?
Please provide the reason for the same.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It depends on what you want to achieve, for example if you have requirement to display data from database query in linear layout, because of dynamic data you don’t know what fields you need to define and how many fields you need to define, in this case, you will have XML as skeleton and will implement real field add logic in java code.
Another case where you know ahead of time how many fields your layout may have, for example login form, in this case it is very simple to define in XML, I feel the main reason is you don’t need to write whole lot of java code.