Reputation: 10948
I was watching thenewboston Android tutorials and I got lost in this line of code:
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
I think getWindow()
and setFlags()
are a method, but why they can be accessed like that? The one that I always see is ClassObject.Method
but this time it's Method.Method
.
Upvotes: 1
Views: 119
Reputation: 87064
It works because the first method(from the activity) returns an object (Window
) on which you can call the second method. You could do :
Window obj = getWindow();
obj.setFlags();
if it makes more sense to you.
Upvotes: 1
Reputation: 4960
getWindow() returns an object of type Window, on which one can use the setFlags() method
So it is basically a geeky way of writing
Window a = getWindow();
a.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
Upvotes: 3
Reputation: 5407
Because getWindows()
is a Method from the Class Activity
.
And it returns an object from the Class Window
which represents your actuall Screen-window.
So setFlags()
is actually called on the Window-Class.
Upvotes: 2