Just got started with Android programming and i got a task where im supposed to fill in two textfields and then click a button for a new frame to come up with some more textfields.
I decided to change the contentView to a 2nd xml file i created when you click that button. However im not able to use the widgets inside that 2nd xml file until i change the contentview? I wanna add clicklisteners and so on which i cant on the buttons that arent visible yet..
Should i use another approach or am i just retarded?
If you want everything to be in one Activity (which is supposed to represent a single screen), you can specify all your views in a single XML file, and set the visibility of the views you want hidden at first to
invisibleorgone. Then you can show them later. Since everything is in a single XML layout, you can access the Views even if they are not visible, but the user will not see them.To set visibility in Java you use
view.setVisibility(int visibility)where the integer isView.VISIBLE,View.INVISIBLEorView.GONE.