-1

Sorry if you don't understand my question. I try to explain. So in java we create object like Class object = new Class(); something like that. And then use this object to access class methods and instances like object.method(); something like that. But in android when we access some xml we use TextView textView; and then textView = findViewById(R.id.tvTempText); something like that. So for me confusing part is why not we use something like that TextView textView = new TextView(); and then use object like that textView.findViewById(R.id.tvTempText);

Yasir
  • 1

1 Answers1

0

Findviewbyid() has a return type of view so then we r assigning findviewbyid() methods return value to the textview object as textview extends view class.

Prajwal Waingankar
  • 2,534
  • 2
  • 13
  • 20
  • ok But why we not instantiate object like TextView textView = new TextView(); How we can use object without instantiate it. For example in above we only declare object TextView textView; but we not instantiate object. so how can we use object without instantiate. – Yasir Oct 25 '20 at 16:24
  • There is difference between variable nd object and when we use findviewbyid() it's not an object to which we reference it, it's a variable of type view. – Prajwal Waingankar Oct 25 '20 at 16:50