Recently I have experimented with the use of gestures in my app. Most tutorials I have come across are based on setting GestureOverlayView in an Activity where you can setContentView. However, this cannot be done in a Fragment. As such, how can I go about setting a GestureOverlayView over my ListFragment for example?
Any help will be deeply appreciated. Thanks!
This what I use for my fragment with gesture overlay
This snippet is part of the fragment that has the GestureOverlayView
.
...
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
Context context = container.getContext();
View root = inflater.inflate(R.layout.myfragment,container,false);
GestureOverlayView gestureoverlay =
(GestureOverlayView) root.findViewById(R.id.gestureOverlayView);
gestureoverlay.addOnGesturePerformedListener(
new MyGestureListener(context));
...
return root;
}
...
Where the R.id.gestureOverlayView
part is of the layout that is inflated by this fragment
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With