So I currently have some code that will populate a page with a number of TextViews and Buttons onCreate, and these are for selecting dates and times. I want to have a button that will add shifts which would bring up another two copies of the buttons and the TextViews as well.
So I was just wondering how I would go about doing this.
I know how to set up OnClickListeners with no issues, I’m just unsure what I have to do to create new objects that would use the XML layout properties I have already created in my main.xml file, when the button is clicked.
Any help would be appreciated, thanks.
So I currently have some code that will populate a page with a number
Share
What you should do is create everything you need in main.xml initially, but hide the stuff you aren’t going to be displaying right away. Then in your OnClickListener, you can show/hide whatever it is you want using the setVisibility() method. So your xml would look something like this:
The visibility attribute actually has three values it can take on: visibile, invisible, and gone. Which one you pick will depend on your implementation needs. For more information see this documentation.