archive-com.com » COM » T » TECHOTOPIA.COM

Total: 1018

Choose link from "Titles, links and description words view":

Or switch to "Titles and links view".
  • Designing a User Interface using the Android Studio Designer Tool - Techotopia
    The very simple user interface design is now complete Designing a more complex user interface layout is a continuation of the steps outlined above Simply drag and drop views onto the display position and set properties as needed and nest layouts as required Running the Application All that remains is to test that the application runs Click on the run button in the main window toolbar Select either the simulator or a physical Android device and wait for the application to start Assuming the absence of errors the application and activity should launch and appear exactly as designed using the Designer tool Manually Creating an XML Layout Whilst the design of layouts using the layout tool greatly improves productivity it is still possible to create XML layouts by manually editing the XML The structure of an XML layout file is actually quite straightforward and follows the hierarchical approach of the view tree The first line of an XML resource file should ideally include the following standard declaration xml version 1 0 encoding utf 8 This declaration should be followed by the root element of the layout typically a container view such as a layout manager This is represented by both opening and closing tags and any properties that need to be set on the view The following XML for example declares a RelativeLayout view as the root element and sets match parent properties such that it fills all the available space of the device display with padding on each side of 64 density independent pixels RelativeLayout xmlns android http schemas android com apk res android xmlns tools http schemas android com tools android layout width match parent android layout height match parent android paddingLeft 64dp android paddingRight 64dp android paddingTop 64dp android paddingBottom 64dp tools context com ebookfrenzy layoutsample layoutsample LayoutSampleActivity RelativeLayout eBookFrenzy com Purchase the fully updated Android 6 Edition of this Android Studio Development Essentials publication in eBook 9 99 or Print 38 99 format Android Studio Development Essentials Android 6 Edition Print and eBook ePub PDF Kindle editions contain 65 chapters Any children that need to be added to the RelativeLayout parent must be nested within the opening and closing tags In the following example a Button and an EditText field have been added as children of the RelativeLayout view RelativeLayout xmlns android http schemas android com apk res android xmlns tools http schemas android com tools android layout width match parent android layout height match parent android paddingLeft 64dp android paddingRight 64dp android paddingTop 64dp android paddingBottom 64dp tools context com ebookfrenzy layoutsample layoutsample LayoutSampleActivity Button android layout width wrap content android layout height wrap content android text string button string android id id button android layout centerVertical true android layout centerHorizontal true EditText android layout width wrap content android layout height wrap content android id id editText android layout above id button android layout centerHorizontal true android layout marginBottom 51dp android inputType text android width 350dp RelativeLayout Also note that the two child views have

    Original URL path: http://www.techotopia.com/index.php/Designing_a_User_Interface_using_the_Android_Studio_Designer_Tool (2016-02-13)
    Open archived version from archive


  • Creating an Android User Interface in Java Code using Android Studio - Techotopia
    Project in Android Studio Launch Android Studio and select the Start a new Android Studio project option from the quick start list in the welcome screen If any existing projects are already open close them first using the File Close menu option In the new project configuration dialog enter JavaLayout into the Application name field and ebookfrenzy com as the Company Domain setting before clicking on the Next button On the form factors screen enable the Phone and Tablet option and set the minimum SDK setting to API 8 Android 2 2 Froyo Continue to proceed through the screens requesting the creation of a blank activity named JavaLayoutActivity with a corresponding layout named activity java layout and with the menu resource name set to menu java layout Once the project has been created the JavaLayoutActivity java file should automatically load into the editing panel As we have come to expect Android Studio has created a template activity and overridden the onCreate method providing an ideal location for Java code to be added to create a user interface Adding Views to an Activity The onCreate method is currently designed to use a resource layout file for the user interface Begin therefore by deleting this line from the method Override protected void onCreate Bundle savedInstanceState super onCreate savedInstanceState setContentView R layout activity java layout The next modification to the onCreate method is to write some Java code to add a RelativeLayout object with a single Button view child to the activity This involves the creation of new instances of the RelativeLayout and Button classes The Button view then needs to be added as a child to the RelativeLayout view which in turn is displayed via a call to the setContentView method of the activity instance package com ebookfrenzy javalayout import android support v7 app ActionBarActivity import android os Bundle import android view Menu import android view MenuItem import android widget Button import android widget RelativeLayout public class JavaLayoutActivity extends ActionBarActivity Override protected void onCreate Bundle savedInstanceState super onCreate savedInstanceState Button myButton new Button this RelativeLayout myLayout new RelativeLayout this myLayout addView myButton setContentView myLayout Once the above additions have been made compile and run the application either on a physical device or an emulator Once launched the visible result will be a button containing no text appearing in the top left hand corner of the RelativeLayout view as shown in Figure 17 1 Figure 17 1 Setting View Properties For the purposes of this exercise we need the background of the RelativeLayout view to be blue and the Button view to display text that reads Press Me Both of these tasks can be achieved by setting properties on the views in the Java code as outlined in the following code fragment package com ebookfrenzy javalayout import android support v7 app ActionBarActivity import android os Bundle import android view Menu import android view MenuItem import android widget Button import android widget RelativeLayout import android graphics Color public class JavaLayoutActivity extends ActionBarActivity Override protected void onCreate Bundle savedInstanceState super onCreate savedInstanceState Button myButton new Button this myButton setText Press Me myButton setBackgroundColor Color YELLOW RelativeLayout myLayout new RelativeLayout this myLayout setBackgroundColor Color BLUE myLayout addView myButton setContentView myLayout When the application is now compiled and run the layout will reflect the property settings such that the layout will appear with a blue background and the button will display the assigned text on a yellow background eBookFrenzy com Purchase the fully updated Android 6 Edition of this Android Studio Development Essentials publication in eBook 9 99 or Print 38 99 format Android Studio Development Essentials Android 6 Edition Print and eBook ePub PDF Kindle editions contain 65 chapters Adding Layout Parameters and Rules By default the RelativeLayout view has placed the button view in the top left corner of the display In order to instruct the layout view to place the button in a different location in this case centered both horizontally and vertically it will be necessary to create a LayoutParams object and initialize it with the appropriate values Typically a new LayoutParams instance is created by passing through the height and width values for the view These values should be set to either MATCH PARENT WRAP CONTENT or specific size values The MATCH PARENT setting instructs the parent layout to expand the child view so that it matches the size of the parent WRAP CONTENT on the other hand instructs the parent to size the child view so that it is only large enough to display any content it may be configured to show to the user The code to create a LayoutParams object for our button would read as follows RelativeLayout LayoutParams buttonParams new RelativeLayout LayoutParams RelativeLayout LayoutParams WRAP CONTENT RelativeLayout LayoutParams WRAP CONTENT The above code creates a new RelativeLayout LayoutParams object named buttonParams and sets the height and width such that the button will only be large enough to display the Press Me text previously configured via the property setting Now that the LayoutParams object has been created the next step is to add some additional rules to the parameters to instruct the layout parent to center the button vertically and horizontally This is achieved by calling the addRule method of the buttonParams object passing through the appropriate values as arguments buttonParams addRule RelativeLayout CENTER HORIZONTAL buttonParams addRule RelativeLayout CENTER VERTICAL Simply creating a new LayoutParams object and configuring it is only useful if that object is then assigned to the child view One way to achieve this is to pass the LayoutParams object through as an argument when the child view is added to the parent myLayout addView myButton buttonParams Alternatively the parameters can be assigned to the child via a call to the setLayoutParams method of the view myButton setLayoutParams buttonParams Bringing these together results in a modified onCreate method that reads as follows Override protected void onCreate Bundle savedInstanceState super onCreate savedInstanceState Button myButton new Button this myButton setText Press me myButton setBackgroundColor Color YELLOW RelativeLayout myLayout

    Original URL path: http://www.techotopia.com/index.php/Creating_an_Android_User_Interface_in_Java_Code_using_Android_Studio (2016-02-13)
    Open archived version from archive

  • Using the Android GridLayout Manager in Android Studio Designer - Techotopia
    enough to accommodate the child views contained therein As such the height and width parameters of the GridLayout view need to be changed from fill parent to wrap content One way to make this change is to locate the properties in the Designer tool s Properties panel A quicker option is to select the GridLayout instance and use the two buttons in the Designer toolbar Set the width property by clicking on the layout width button as highlighted in Figure 18 2 Figure 18 2 Having set the width property to wrap content click on the adjacent toolbar button to similarly set the layout height property These settings will have the effect of shrinking the layout down to a small square ready to accommodate some child views If the GridLayout instance is still positioned in the center of the screen click and drag it to the upper left hand corner Adding Views to GridLayout Cells To place view objects into the cells of a GridLayout simply click on the required view in the palette and drag it to the GridLayout instance in the device screen layout canvas As the view passes over the GridLayout information will appear indicating the placement of the view if it is dropped at that point Begin by clicking and dragging a Button view from the palette over to the top right hand corner of the GridLayout as illustrated in Figure 18 3 Figure 18 3 As is evident from the message displayed by the tool releasing the view at this point will position it in the cell referenced by the co ordinates of 0 0 Release the view at this point and note that the Button is placed in the cell as shown in Figure 18 4 Figure 18 4 Note also that green bars have appeared in the margins on the upper and right hand sides of the main Designer area These bars represent the rows and columns present in the GridLayout currently the layout has one row and one column Repeat the above steps to place a second button into the GridLayout so that it is positioned in row zero and after column 0 such that it appears immediately to the right of the first button Drag a third Button view to a position to the left of the first Button view until the message shown in Figure 18 6 appears providing the option to shift column 0 right and insert the new view into the cell at 0 0 Figure 18 5 When the view is dropped at this position the existing columns will be shifted one place to the right a new column will be inserted at the left hand edge of the GridLayout and the new button placed into the cell Following the same sequence of steps add one Button view on the second row of the grid positioned after row 0 in column 0 so that the layout resembles that of Figure 18 6 Figure 18 6 eBookFrenzy com

    Original URL path: http://www.techotopia.com/index.php/Using_the_Android_GridLayout_Manager_in_Android_Studio_Designer (2016-02-13)
    Open archived version from archive

  • Working with the Android GridLayout using XML Layout Resources - Techotopia
    following example XML declares a 2 x 2 GridLayout configuration in horizontal orientation GridLayout xmlns android http schemas android com apk res android xmlns tools http schemas android com tools android id id GridLayout1 android layout width wrap content android layout height wrap content android columnCount 2 android rowCount 2 android orientation horizontal tools context GridLayoutActivity GridLayout Adding Child Views to the GridLayout google ADSDAQBOX FLOW google Child views can be added to a GridLayout by declaring the elements within the GridLayout structure in the XML file If no row and column values are declared for a child it is positioned automatically by the GridLayout class based on the configuration of the layout and the position of the view in the XML file The following XML places four buttons within the above GridLayout with each view placed in the top left hand corner of the encapsulating cell GridLayout xmlns android http schemas android com apk res android xmlns tools http schemas android com tools android id id GridLayout1 android layout width wrap content android layout height wrap content android columnCount 2 android rowCount 2 android orientation horizontal tools context GridLayoutActivity Button android id id button1 android layout gravity left top android text Button Button android id id button2 android layout gravity left top android text Button Button android id id button3 android layout gravity left top android text Button Button android id id button4 android layout gravity left top android text Button GridLayout The above layout would be visually represented as illustrated in Figure 19 1 Figure 19 1 eBookFrenzy com Purchase the fully updated Android 6 Edition of this Android Studio Development Essentials publication in eBook 9 99 or Print 38 99 format Android Studio Development Essentials Android 6 Edition Print and eBook ePub PDF Kindle editions contain 65 chapters A view can be placed within a specific cell by specifying the intersecting row and column number of the destination cell The following Button view for example will be placed in the cell located at row 1 column 2 of the parent GridLayout Button android id id button5 android layout column 2 android layout row 1 android layout gravity left top android text Button Declaring Cell Spanning Gravity and Margins The child of a GridLayout can be configured to span multiple cells using the android layout rowSpan and android layout columnSpan properties The gravity of the child is controlled via the android layout gravity property In the XML fragment below a Button view is configured to span 3 columns and 2 rows and to fill the space available both horizontally and vertically Button android id id button4 android layout columnSpan 3 android layout rowSpan 2 android layout gravity fill android text Button The margins around a view within a cell can be declared for all sides of the view using the android layout margin margin property Alternatively margins for individual sides may be defined using the topMargin bottomMargin leftMargin and rightMargin properties The following Button view declares a 10dp

    Original URL path: http://www.techotopia.com/index.php/Working_with_the_Android_GridLayout_using_XML_Layout_Resources (2016-02-13)
    Open archived version from archive

  • An Overview and Android Studio Example of Android Event Handling - Techotopia
    that the event has been processed Create a new project in Android Studio entering EventExample into the Application name field and ebookfrenzy com as the Company Domain setting before clicking on the Next button On the form factors screen enable the Phone and Tablet option and set the minimum SDK setting to API 8 Android 2 2 Froyo Continue to proceed through the screens requesting the creation of a blank activity named EventExampleActivity with corresponding layout and menu resource files named activity event example and menu event example respectively Designing the User Interface The user interface layout for the EventExampleActivity class in this example is to consist of a RelativeLayout view a Button and a TextView as illustrated in Figure 20 1 Figure 20 1 Locate and select the activity event example xml file created by Android Studio located in the Project tool window under app res layouts and double click on it to load it into the Designer tool Switch from Design mode to Text mode using the tab at the bottom of the Designer panel and delete the current content of the file With a blank canvas either use Design mode to visually design the user interface from Figure 20 1 making sure to change the IDs of the Button and TextView objects to id myButton and id myTextView respectively or directly enter the following XML using Text mode xml version 1 0 encoding utf 8 RelativeLayout xmlns android http schemas android com apk res android android id id myLayout android layout width fill parent android layout height fill parent Button android id id myButton android layout width wrap content android layout height wrap content android layout centerHorizontal true android layout centerVertical true android text Press Me TextView android id id myTextView android layout width wrap content android layout height wrap content android layout above id myButton android layout centerHorizontal true android layout marginBottom 41dp android text Status android textAppearance android attr textAppearanceLarge RelativeLayout Switch to Design mode and select the Status label in the device screen layout When the light bulb icon appears click on it and select the I18N hardcoded string warning message to display the Extract Resource dialog Within the dialog name the resource string status string and click on the OK button Repeat these steps for the button view this time naming the string resource button string With the user interface layout now completed the next step is to register the event listener and callback method eBookFrenzy com Purchase the fully updated Android 6 Edition of this Android Studio Development Essentials publication in eBook 9 99 or Print 38 99 format Android Studio Development Essentials Android 6 Edition Print and eBook ePub PDF Kindle editions contain 65 chapters The Event Listener and Callback Method For the purposes of this example an onClickListener needs to be registered for the myButton view This is achieved by making a call to the setOnClickListener method of the button view passing through a new onClickListener object as an argument

    Original URL path: http://www.techotopia.com/index.php/An_Overview_and_Android_Studio_Example_of_Android_Event_Handling (2016-02-13)
    Open archived version from archive

  • Android Touch and Multi-touch Event Handling in Android Studio - Techotopia
    value this should be obtained by converting the ID for a touch to the corresponding index value via a call to the findPointerIndex method of the MotionEvent object An Example Multi Touch Application The example application created in the remainder of this chapter will track up to two touch gestures as they move across a layout view As the events for each touch are triggered the coordinates index and ID for each touch will be displayed on the screen Create a new project in Android Studio entering MotionEvent into the Application name field and ebookfrenzy com as the Company Domain setting before clicking on the Next button On the form factors screen enable the Phone and Tablet option and set the minimum SDK setting to API 8 Android 2 2 Froyo Continue to proceed through the screens requesting the creation of a blank activity named MotionEventActivity with corresponding layout and menu resource files named activity motion event and menu motion event respectively Click on the Finish button to initiate the project creation process Designing the Activity User Interface The user interface for the application s sole activity is to consist of a RelativeLayout view containing two TextView objects Within the Project tool window navigate to app res layout and double click on the activity motion event xml layout resource file to load it into the Android Studio Designer tool One option is to design the layout illustrated in Figure 21 1 using a RelativeLayout as the root view and keeping in mind that the lower TextView component is centered horizontally within the parent view and the upper TextView is positioned a relative distance above the lower TextView When the layout design is complete double click on the RelativeLayout essentially the background of the layout and set the ID to id RelativeLayout1 Repeat these steps to assign IDs id textView1 and id textView2 to the TextView components Alternatively switch to the XML editor by selecting the Text tab at the bottom of the Designer panel and replace the current XML with the following RelativeLayout xmlns android http schemas android com apk res android android id id RelativeLayout1 android layout width fill parent android layout height fill parent TextView android id id textView2 android layout width wrap content android layout height wrap content android layout centerHorizontal true android layout centerVertical true android text Touch Two Status TextView android id id textView1 android layout width wrap content android layout height wrap content android layout above id textView2 android layout alignLeft id textView2 android layout marginBottom 47dp android text Touch One Status RelativeLayout Switch to Design mode and select the upper TextView in the device screen layout When the light bulb icon appears click on it and select the I18N hardcoded string warning message to display the Extract Resource dialog Within the dialog name the resource string status1 string and click on the OK button Repeat these steps for the second TextView component this time naming the string resource status2 string Figure 21 1

    Original URL path: http://www.techotopia.com/index.php/Android_Touch_and_Multi-touch_Event_Handling_in_Android_Studio (2016-02-13)
    Open archived version from archive

  • Detecting Common Gestures using Android Studio and the Gesture Detector Class - Techotopia
    Create a new project in Android Studio entering CommonGestures into the Application name field and ebookfrenzy com as the Company Domain setting before clicking on the Next button On the form factors screen enable the Phone and Tablet option and set the minimum SDK setting to API 8 Android 2 2 Froyo Continue to proceed through the screens requesting the creation of a blank activity named CommonGesturesActivity with a corresponding layout and menu resource files named activity common gestures and menu common gestures respectively Click on the Finish button to initiate the project creation process Once the new project has been created navigate to the app res layout activity common gestures xml file in the Project tool window and double click on it to load it into the Designer tool Within the Designer tool double click on the Hello World TextView component and in the property popup window enter gestureStatusText as the ID Finally move the TextView so that it is positioned in the center of the display Implementing the Listener Class As previously outlined it is necessary to create a class that implements the GestureDetector OnGestureListener interface and if double tap detection is required the GestureDetector OnDoubleTapListener interface Whilst this can be an entirely new class it is also perfectly valid to implement this within the current activity class For the purposes of this example therefore we will modify the CommonGesturesActivity class to implement these listener interfaces Edit the CommonGesturesActivity java file so that it reads as follows to declare the interfaces and to extract and store a reference to the TextView component in the user interface package com ebookfrenzy commongestures import android support v7 app ActionBarActivity import android os Bundle import android view Menu import android view MenuItem import android view GestureDetector import android widget TextView public class CommonGesturesActivity extends ActionBarActivity implements GestureDetector OnGestureListener GestureDetector OnDoubleTapListener private TextView gestureText Override protected void onCreate Bundle savedInstanceState super onCreate savedInstanceState setContentView R layout activity common gestures gestureText TextView findViewById R id gestureStatusText eBookFrenzy com Purchase the fully updated Android 6 Edition of this Android Studio Development Essentials publication in eBook 9 99 or Print 38 99 format Android Studio Development Essentials Android 6 Edition Print and eBook ePub PDF Kindle editions contain 65 chapters Declaring that the class implements the listener interfaces mandates that the corresponding methods also be implemented in the class package com ebookfrenzy commongestures import android support v7 app ActionBarActivity import android os Bundle import android view Menu import android view MenuItem import android view GestureDetector import android widget TextView import android view MotionEvent public class CommonGesturesActivity extends ActionBarActivity implements GestureDetector OnGestureListener GestureDetector OnDoubleTapListener private TextView gestureText Override protected void onCreate Bundle savedInstanceState super onCreate savedInstanceState setContentView R layout activity common gestures gestureText TextView findViewById R id gestureStatusText Override public boolean onDown MotionEvent event gestureText setText onDown return true Override public boolean onFling MotionEvent event1 MotionEvent event2 float velocityX float velocityY gestureText setText onFling return true Override public void onLongPress MotionEvent event gestureText setText onLongPress Override public

    Original URL path: http://www.techotopia.com/index.php/Detecting_Common_Gestures_using_Android_Studio_and_the_Gesture_Detector_Class (2016-02-13)
    Open archived version from archive

  • Implementing Android Custom Gesture Recognition with Android Studio - Techotopia
    Studio entering CustomGestures into the Application name field and ebookfrenzy com as the Company Domain setting before clicking on the Next button On the form factors screen enable the Phone and Tablet option and set the minimum SDK setting to API 8 Android 2 2 Froyo Continue to proceed through the screens requesting the creation of a blank activity named CustomGesturesActivity with corresponding layout and menu resource files named activity custom gestures and menu custom gestures Click on the Finish button to initiate the project creation process eBookFrenzy com Purchase the fully updated Android 6 Edition of this Android Studio Development Essentials publication in eBook 9 99 or Print 38 99 format Android Studio Development Essentials Android 6 Edition Print and eBook ePub PDF Kindle editions contain 65 chapters Adding the Gestures File to the Project Within the Android Studio Project tool window locate and right click on the res folder located under app and select New Directory from the resulting menu In the New Directory dialog enter raw as the folder name and click on the OK button Using the appropriate file explorer utility for your operating system type locate the gestures file previously pulled from the SD Card and copy and paste it into the new raw folder in the Project tool window Designing the User Interface This example application calls for a very simple user interface consisting of a LinearLayout view with a GestureOverlayView layered on top of it to intercept any gestures performed by the user Locate the app res layout activity custom gestures xml file and double click on it to load it into the Designer tool By default Android Studio has provided a RelativeLayout component as the root element of the user interface layout so this will need to be deleted and replaced with a LinearLayout Switch the Designer tool to Text mode using the Text tab along the bottom edge of the panel and modify the XML for the layout so that it matches that in the following listing LinearLayout android orientation vertical android layout width fill parent android layout height fill parent xmlns android http schemas android com apk res android LinearLayout Return to Design mode locate the Expert section of the Palette and drag and drop a GestureOverlayView object onto the layout canvas Select the GestureOverlayView instance in the layout and use the Properties panel or Designer toolbar buttons to change the layout width and layout height properties to match parent so that the view fills the available space Double click on the GestureOverlayView instance and use the popup property panel to change the ID to id gOverlay When completed the activity custom gestures xml file should read as follows LinearLayout android orientation vertical android layout width fill parent android layout height fill parent xmlns android http schemas android com apk res android android weightSum 1 android gesture GestureOverlayView android layout width match parent android layout height match parent android id id gOverlay android layout gravity center horizontal android gesture GestureOverlayView LinearLayout Loading the Gestures File Now that the gestures file has been added to the project the next step is to write some code so that the file is loaded when the activity starts up For the purposes of this project the code to achieve this will be placed in the onCreate method of the CustomGesturesActivity class located in the CustomGesturesActivity java source file as follows package com ebookfrenzy customgestures import android support v7 app ActionBarActivity import android os Bundle import android view Menu import android view MenuItem import android gesture GestureLibraries import android gesture GestureLibrary import android gesture GestureOverlayView import android gesture GestureOverlayView OnGesturePerformedListener public class CustomGesturesActivity extends ActionBarActivity implements OnGesturePerformedListener private GestureLibrary gLibrary Override protected void onCreate Bundle savedInstanceState super onCreate savedInstanceState setContentView R layout activity custom gestures gLibrary GestureLibraries fromRawResource this R raw gestures if gLibrary load finish In addition to some necessary import directives the above code changes to the onCreate method also create a GestureLibrary instance named gLibrary and then loads into it the contents of the gestures file located in the raw resources folder The activity class has also been modified to implement the OnGesturePerformedListener interface which requires the implementation of the onGesturePerformed callback method which will be created in a later section of this chapter Registering the Event Listener In order for the activity to receive notification that the user has performed a gesture on the screen it is necessary to register the OnGesturePerformedListener event listener on the gLayout view a reference to which can be obtained using the findViewById method as outlined in the following code fragment Override protected void onCreate Bundle savedInstanceState super onCreate savedInstanceState setContentView R layout activity custom gestures gLibrary GestureLibraries fromRawResource this R raw gestures if gLibrary load finish GestureOverlayView gOverlay GestureOverlayView findViewById R id gOverlay gOverlay addOnGesturePerformedListener this Implementing the onGesturePerformed Method All that remains before an initial test run of the application can be performed is to implement the OnGesturePerformed callback method This is the method which will be called when a gesture is performed on the GestureOverlayView instance package com ebookfrenzy customgestures import android support v7 app ActionBarActivity import android os Bundle import android view Menu import android view MenuItem import android gesture GestureLibraries import android gesture GestureLibrary import android gesture GestureOverlayView import android gesture GestureOverlayView OnGesturePerformedListener import android gesture Prediction import android widget Toast import android gesture Gesture import java util ArrayList public class CustomGesturesActivity extends ActionBarActivity implements OnGesturePerformedListener private GestureLibrary gLibrary Override protected void onCreate Bundle savedInstanceState super onCreate savedInstanceState setContentView R layout activity custom gestures gLibrary GestureLibraries fromRawResource this R raw gestures if gLibrary load finish GestureOverlayView gOverlay GestureOverlayView findViewById R id gOverlay gOverlay addOnGesturePerformedListener this public void onGesturePerformed GestureOverlayView overlay Gesture gesture ArrayList Prediction predictions gLibrary recognize gesture if predictions size 0 predictions get 0 score 1 0 String action predictions get 0 name Toast makeText this action Toast LENGTH SHORT show When a gesture on the gesture overlay view object is detected by the Android runtime the onGesturePerformed method is

    Original URL path: http://www.techotopia.com/index.php/Implementing_Android_Custom_Gesture_Recognition_with_Android_Studio (2016-02-13)
    Open archived version from archive



  •