The need to call FindViewById
is a really messed up way to get the View inside an Activity
. It may cause an exception at runtime, if the view does not exist in the layout.
Is there a layout generator to generate the Activity
with all known Views as member variables (like in Windows.Forms or better WPF) in order to get Activities typesafe?
Cons
- It's not typesafe
- It's timeconsuming to implement
- Not error prone, causing exceptions at runtime
- Writing a lot of boilerplate code
Advantages
May have lower memory impact, when there are a lot unused Views, that don't need a member variable
A little better load performance.
So that instead of this:
EditText _editText;
// ...
_editText = FindViewById(Resource.Id.editText1);
_editText.Text = "Hallo World!";
I end up with just this:
_editText.Text = "Hallo World!";
The prefered way would be to utilize Androids Data Binding. But this is not available for Xamarin.