Android get child of DecorView

I wonder if it is possible to get a child of decorViews. For example, if I have a decorView, and I know that the child of the decorView is FrameLayout, can I somehow get the FrameLayout object only with its parent?

Obviously, I could use getViewById () in the traditional way, but if I only want to use the parent object, is it possible to get the FrameLayout object?

Thanks,

+3
source share
1 answer

Are you talking about object inheritance?

If so, then it is simple: drop it.

, "Foo", - "Bar" ( : Bar "" Foo), :

Foo myFoo = getSomeFoo();
Bar myBar = (Bar)myFoo;

, :

View myView = getDecorView();
FrameLayout myFrameLayout = (FrameLayout) myView;

FrameLayout myFrameLayout = (FrameLayout) getDecorView();

, , , ClassCastException, , getDecorView, FrameLayout ( (in)). try/catch throwing , . .

+1

Source: https://habr.com/ru/post/1720897/


All Articles