I have a TabActivity with 2 tabs that contain a control that responds to Scale and Scroll events.
When I fire up my app to begin with it starts on Tab 1 and I can scale and scroll the view shown on the 1st Tab’s activity.
When I switch to Tab 2 again I can scale and scroll the view shown on the 2nd tab’s activity.
All looks good.
When I switch back to the 1st tab suddenly I can no longer scale or scroll. If i switch back to the 2nd again then that one works fine. Its as if the touch focus is being taken by the view on the 2nd tab and never being surrendered.
I’ve even tried re-initialising my GestureDetectors in case they somehow get destroyed when one Activity gets backgrounded.
I’ve tried the following code to no avail:
public void onPause()
{
super.onPause();
mView.clearFocus();
}
public void onResume()
{
super.onResume();
mView.requestFocus();
mView.InitGestureDetectors( this );
}
Where InitGestureDetectors simply does the following:
public void InitGestureDetectors( Context ctx )
{
mScaleGestureDetector = new ScaleGestureDetector( ctx, new ScaleGestureListener() );
mGestureDetector = new GestureDetector( ctx, new GestureListener() );
}
Can anyone tell me how I can get my touch gestures working again when i subsequently switch tabs?
I’ve eventually tracked down the source of my problems. This was being caused by a custom OnTabChangeListener used to create a transition animation when you change tabs. This caused, for some reason, the visibility state to not get set to GONE when a view moved into the background. So i added a custom AnimationListener to set the visibility flag appropriately in onAnimationEnd and onAnimationStart.
and now my touch events are being handled as I would expect!