I\'m new to Android development and have started creating my own UI. I see that you can either create it dynamically something like this (Dynamic Layouts):
@
Layout based on XML depends on casting, because you have to use:
Button myButton = (Button) findViewById(R.id.my_button);
so you have one casting and time consuming XML searching. When you use dynamic creation of a UI is much more difficult to manage it. You have to organize everything but you don't need to cast as much.
I prefer the third solution - RoboGuice It uses dependency injection pattern and you don't care about casting and it's faster to create an app. Also more flexible. Consider that you have a normal text field. Then you want to change it to text area. In RoboGuice it's only matter of 2 changes (except usage changes). It's also faster when you use Context (Context is very memory consuming object and storing reference to it is sign of bad coding).
So my advice is: use XML because of it's simplicity to manage UI. Use RoboGuice to code fast.