เนื่องจากการสร้าง Custom View แต่ละวิว ถูกสร้างขึ้นจากคลาสเดียวกัน ดังนั้น การแยกแยะความแตกต่างจำเป็นต้องติดป้าย(Tag) แต่ละวิวไว้
www.b4x.com
จำเป็นต้องเขียน
ตัวอย่างการใช้งาน
[B4X] How to get <custom view here> from <CLV or any other container>
This is a common question and for a good reason. Custom views classes are not views by themselves. The views tree only holds views. This means that this code cannot work: Dim B4XFloatTextField1 As B4XFloatTextField = CLV.GetPanel(x).GetView(y) The actual view that is added to the views tree...
B4X:
Dim B4XFloatTextField1 As B4XFloatTextField = CLV.GetPanel(x).GetView(y) '<--ไม่สามารถทำงานได้
จำเป็นต้องเขียน
B4X:
Dim B4XFloatTextField1 As B4XFloatTextField = CLV.GetPanel(x).GetView(y).Tag '<--สามารถทำงานได้
ตัวอย่างการใช้งาน
B4X:
Activity.LoadLayout("1")
clv.AsView.Tag = clv
'เราจึงจะสามารถแยกแยะ Custom View ได้
Dim c As CustomListView = Activity.GetView(<clv index>).Tag
Last edited: