I have a big problem. In systemUI/PhoneStatusBar
class, I want to add a childView to parrent of current View
of running Activity
. How to done it in PhoneStatusBar.java
in systemUI
. I tried to using some method, example
View.getRootView()
or so on, but cannot get expected result. Hope to get success from everyone. Thanks very much
Thanks for help from you. But i would like to emphasized that "I want to get current view of running activity". I it must be done in android/frameworks/base/packages//Systemui/statusbar/phone/PhoneStatusBar.java. I very very hope to continue receiving helps from everyone
Try
View.getContext();
It should work.
To add a view, you need to cast it as a ViewGroup:
ViewGroup addViewHere = (ViewGroup)myView;
Or you may need to get the parent if the problem is that you cannot add the view to the correct place in the view hierarchy:
ViewGroup addViewHere = (ViewGroup)myView.getParent();
Then assuming all layout params are correct, add it:
addViewHere.addView(newView);
You can try this:
findViewById(android.R.id.content).getRootView()
It should give you the root view of the activity including status bar on top
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.