I am building an android app and I am accssing the UI elements with the following method :
FindViewById
The thing is it looks like I cannot access elements that are not in the currently opened layout.
Is that possible ? If so, how can I access elements that are not in the currently loaded layout.
SetContentView (Resource.Layout.CameraLayout);
Button button1 = FindViewById<Button> (Resource.Id.firstButton);
Button button2 = FindViewById<Button> (Resource.Id.secondButton);
button1.Click += (s,e) => {//do stuff}; // In CameraLayout layout.
button2.Click += (s,e) => {//do stuff}; // Not in CameraLayout layout.
This line will throw the null exception : button2.Click += (s,e) => {//do stuff};
But if I change it to :
SetContentView (Resource.Layout.AnotherLayout);
Button button1 = FindViewById<Button> (Resource.Id.firstButton);
Button button2 = FindViewById<Button> (Resource.Id.secondButton);
button1.Click += (s,e) => {//do stuff}; // Not AnotherLayout layout.
button2.Click += (s,e) => {//do stuff}; // In AnotherLayout layout.
This line will throw the null exception : button1.Click += (s,e) => {//do stuff};
So I can only access elements form the currently loaded layout. I highly doubt that there is no way to access the other elements but I still can't find how.