0

I am using an SDK which is displaying a popup on performing some action in app. By using WindowManager i am able to get views on the screen as:

  • 1) My home screen (android.view.ViewRootImpl@e33bea5: DecorView@82c1e88[Dashboard])
  • 2) Login success Toast (Toast/android.view.ViewRootImpl@8bca27a: android.widget.LinearLayout)
  • 3) com.PopupActivity/android.view.ViewRootImpl@62e8a2b: DecorView@d099e07[PopupActivity]

The 3rd one (PopupActivity) has 2 children:

  • 1) ViewStub
  • 2) ImageButton

I am able to access ImageButton like, ((ImageButton)obj).performClick(); but i am not able to access the contents of ViewStub. ViewStub has only few methods like getInflaterId(), getLayoutResource(), etc.

I have seen some articles saying, we can initially take the layout id which is inside view stub and then keep playing with that layout id, whereas in my case, i dont know the layout id because the SDK in inflating that viewstub.

Now, How do i access the contents of ViewStub?

some user
  • 1,693
  • 2
  • 14
  • 31
  • posting `PopupActicvity` minimally, might make question bit more clear – some user Feb 07 '20 at 04:02
  • You can set id to your `ViewStub` and/any views inside that, then access those. – some user Feb 07 '20 at 04:03
  • I already retrieved the id (object actually) of the view stub. Say "stub" is the ViewStub id, now how do i get the contents of that ViewStub? You are saying any views inside the stub can access "those" (understanding "those" refers to elements inside the layout). But my context is outside (because i am reading those fields from a global class using WindowManager). So, from global context, i want to read the ViewStub contents (layout/elements inside the ViewStub). – Nikhil Reddy Feb 07 '20 at 04:09
  • Let it be inside/outside context, 1st of all, i am trying to read the contents of ViewStub. Is there any predefined method or workaround for it? – Nikhil Reddy Feb 07 '20 at 04:10

0 Answers0