0
I came across a question in android programming, when we declare the views in the java class, as in the example: (Textview txt = (Textview) findViewById (R.id.txt), this View is being used by the class without before it has been instantiated?
0
I came across a question in android programming, when we declare the views in the java class, as in the example: (Textview txt = (Textview) findViewById (R.id.txt), this View is being used by the class without before it has been instantiated?
3
I think you are confusing declaring with initializing/assigning.
On the line
TextView txt = (TextView) findViewById (R.id.txt);
the declaration is being made by
TextView txt
and at the same time, through
= (TextView) findViewById (R.id.txt)
Views are instantiated by Activity during the process of their creation.
The method findViewById(R.id.txt)
takes care of returning the view instance whose id is R.id.txt
, if there is.
Browser other questions tagged android
You are not signed in. Login or sign up in order to post.
Got it. My question was this, where the findViewById(int) method takes care of returning a view instance. Thank you!
– use3265498465