5

I would like to know if there's any concrete way by which we can get notifications on when a view is actually appearing on the screen or disappearing from the screen. I tried almost all the methods of View to see if I get any notifications but didn't get anything useful.

I can somehow workaround & say that a view is currently getting displayed in the visible area of the activity using the 'onDraw()' method. But there's absolutely no way to find out the same when a view goes out of the visible area. Is there anything that can help me in this?

Thanks, Ashok.

Ashok G
  • 121
  • 1
  • 2
  • 6
  • Here is the answer you were looking for: http://stackoverflow.com/questions/8420837/android-sdk-equivlent-for-viewwillappear-ios Looks like you need to use onResume(); – Ethan Allen Jul 14 '12 at 02:07
  • Do you mean ... A view appearing / disappearing inside an activity OR The activity appearing/ disappearing – pellucide Oct 03 '12 at 02:46

1 Answers1

0

You can use a combination of onResume() for the Activity and then on the desired view you can use the getVisibility() method within the onResume().

Or even better if you are supporting only 2.2 and up (API level 8) you can use the onVisibilityChanged event handler for the View class.

zaifrun
  • 931
  • 9
  • 21