Reputation: 13377
i add a view in the windowManager via mWindowManager.addview()
. Now i would like to know if it's possible to get the window
instance. their is myView.getWindowID()
and myView.getWindowToken()
but i can't find a way to retrieve from it the window instance
Upvotes: 11
Views: 11488
Reputation: 556
You cannot get a window
instance from View
or WindowManager
.
But you can get the Display
to which the View's window
is been attached by calling this method myView.getDisplay()
Edited -you can use View.bringToFront();
or View.bringChildToFront(View child);
to reorder the z-index of views.
Upvotes: 2
Reputation: 12147
If your View
has been attached to Activity
, you can do like this.
View view; // your view
if (view.getContext() instanceof Activity) {
Window window = ((Activity) view.getContext()).getWindow();
}
After API 19, there is a convenient method to check, view.isAttachedToWindow()
Upvotes: 7
Reputation: 702
myView.getDisplay() you can use this method to display the View.
Upvotes: -1