Android Question how to refer to custom properties of views that are child of a panel

acorrias

Member
Licensed User
Longtime User
Hi
I wish to know how to refer to object properties when they are accessed trought its parent. That is, I realized that I cannot access properties of views directly, but I have to declare an object with the same type of the view in order to get some custon property.

that is, suppose that the panel p contains a label

so
this doesn't work
B4X:
msgbox(p.getview(1).text,"")

this works
B4X:
dim la as label
la=p.GetView(1)
msgbox(la.text,"")

is there a reason? is an alternative way to access properties. Is it correct?

thanks
Alex
 

somed3v3loper

Well-Known Member
Licensed User
Longtime User
I think the reason is that p.GetView(index) returns a general View and not TextView type so there is no .Text property .
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
I think the reason is that p.GetView(index) returns a general View and not TextView type so there is no .Text property .
Correct.
It is a reference to the correct Object but it is a VIEW.
So you need to cast the view first to a Button, Label, whatever; to get the correct Properties
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…