Its syntax is given below:. Android provides ScaleGestureDetector class to handle gestures like pinch e. In order to use it , you need to instantiate an object of this class. Its syntax is as follow:. The first parameter is the context and the second parameter is the event listener. We have to define the event listener and override a function OnTouchEvent to make it working.
Apart from the pinch gestures , there are other methods available that notify more about touch events. Open the "Gestures Builder" app in your emulator. You will see something like: At present in this emulator, no gestures have been added. Add some gestures by clicking on "Add gesture". Enter a name for your gesture and draw the gesture in the remaining area and click on done. After creating the gestures, the most obvious step is to pull the gesture file and add it to your project.
Step 2 For pulling the gesture file from the emulator. Now click on "Pull a file from device" in the top right corner. Save this file anywhere on your computer. I have saved this with the name "expressions". Name the directory "raw" and choose the type as "raw". Copy the file saved in step 2 expressions in this case , to the clipboard and paste it in the "raw" folder that you created.
Now you can use this file. Gesture; import android. GestureLibraries; import android. GestureLibrary; import android. GestureOverlayView; import android. If you need some basic information regarding gestures on android first — take a look at this article. First you need to define the gestures that should be captured in the application later. You can find the app in the samples directory of your android sdk — e.
Run the gesture builder app on the android emulator. It is important to run the app with a SD card connected — if you need more information on creating virtual SD cards — take a look at this article. The app needs the sdcard to store the captured gestures on it.
Copy the gesture library from the SD card — e. First create a new android application using the android sdk — my AndroidManifest.
Now create an activity called GestureActivity and reference the gesture library — my class looks like this. Add an event listener to the activity and reference the gesture overlay in the GestureActivity — at last my class looks like this:. Tags: adt , Android , capturing , emulator , example , gesture , gesture overlay , gesturebuilder , Snippet , tutorial. This entry was posted on Friday, May 14th, at am and is filed under Android.
You can follow any responses to this entry through the RSS 2.
0コメント