Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Having a GestureOverlayView in a Fragment

Tags:

android

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!

like image 431
kneth Avatar asked Nov 04 '22 12:11

kneth


1 Answers

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

like image 66
Tjeerd Avatar answered Nov 15 '22 12:11

Tjeerd