You could get ViewTreeObserver
instance for your GridView
and use it to listen for events such as onLayout
. You can get ViewTreeObserver
for your View
using View.getViewTreeObserver()
. I am not sure if onLayout
event will be enough for you as it does not exactly mean that a View
is fully drawn but you can give it a try.
Here there is a code sample which you could use to listen for onLayout
event (you could use such code e.g. in onCreate
method of your Activity
):
dashboard.getViewTreeObserver().addOnGlobalLayoutListener(
new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
AlertSomeItemsOfTheListView();
// unregister listener (this is important)
dashboard.getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
});
Note: It is important to unregister listener after it is invoked. If you don't do that it will be invoked on every onLayout
event which is not what we want here (we want it to execute only once).