比如我创建了一个layout,里面有一个button,然后在另外一个界面中include了这个layout四次,接着我想为四个button设置不同的text,应该如何完成?
PS0: 单个button只是举个例子,实际上是一个比较复杂的layoutPS1: 实际应用中如果需要在一个layout中多次使用相同的非官方组件,该如何解决这个问题?
认证高级PHP讲师
Set the id for each include, you can find different Views based on different ids and get the controls in them based on the View.
Directly use findViewById(buttonName) to get the corresponding Button, and then set the corresponding requirements
You cannot just use Java to set it in xml
My friend said earlier that setID is OK, and so is setTAG
xml里可以使用DataBindingTechnical implementation.
xml
DataBinding
Set the id for each include, you can find different Views based on different ids and get the controls in them based on the View.
Directly use findViewById(buttonName) to get the corresponding Button, and then set the corresponding requirements
You cannot just use Java to set it in xml
My friend said earlier that setID is OK, and so is setTAG
xml
里可以使用DataBinding
Technical implementation.