Right now I have a specific group of UI elements(Spinners, edit-boxes, buttons, etc.) which I want to be in the program's UI multiple times. Specifically one copy when the program first loads up and new copies are 'created' and show up in the UI due to user interaction(such as a button press event). I'm aware of using XML to define a specific UI groups but I'm not sure how to properly set up having those groups appear in the UI at the start of the program and by user command within the Java code.
现在我有一组特定的UI元素(旋转器,编辑框,按钮等),我想多次在程序的UI中。特别是当程序首次加载并且“创建”新副本并且由于用户交互(例如按钮按下事件)而在UI中显示时,一个副本。我知道使用XML来定义特定的UI组,但我不确定如何在程序开始时通过用户命令在Java代码中正确设置这些组。
1 个解决方案
#1
0
This should be a good idea implements it group of components as a View subclass, this way you view going to comport as a stand-alone component and ready to re-use.
这应该是一个好主意,它将组件组实现为View子类,这样您就可以将其视为独立组件并准备重新使用。
You can still make the layout.xml to it view, inflate it into the onCreate and assign the behaviour of actions in the components of this group.
您仍然可以将layout.xml设置为视图,将其扩展到onCreate并在该组的组件中分配操作的行为。
#1
0
This should be a good idea implements it group of components as a View subclass, this way you view going to comport as a stand-alone component and ready to re-use.
这应该是一个好主意,它将组件组实现为View子类,这样您就可以将其视为独立组件并准备重新使用。
You can still make the layout.xml to it view, inflate it into the onCreate and assign the behaviour of actions in the components of this group.
您仍然可以将layout.xml设置为视图,将其扩展到onCreate并在该组的组件中分配操作的行为。