Using android gesture on top of menu buttons -
What I want is an option menu where the user can choose to navigate between the menus:
- < Li> To touch a button and then select it on trackball
- Attract predefined gestures from gesture builder
As it stands now, I made my own Gesture with OnClickListener
and the button with GestureOverlayView
After this I select to start a new activity
, depending on whether a pressed button was used or gesture, however, when I try to make a gesture , Then it is not raised. Only pressed buttons is recognized. The following is my code:
Expands the public class menu activity OnClickListener, OnGesturePerformedListener {@Override Creates the bundle saved instenestate {super.onCreate (savedInstanceState) on Public Zero; SetContentView (R.layout.main); // TextToSpike Make myTTS = New TextAutoPike (this, this); MyTTS.setLanguage (Locale.US); // Create gestures mLibrary = Gesture Library. From RRR resources (this, R.O.G. If (! MLibrary.load ()) {finish (); } // Click set listeners for all buttons PlayButton View = ViewById (R.id.play_button); PlayButton.setOnClickListener (this); View instructions button = Find ViewById (R.id.instructions_button); InstructionsButton.setOnClickListener (this); View Mode Mode = Find VeeById (R.id.mode_button); ModeButton.setOnClickListener (this); See statsButton = findViewById (R.id.stats_button); StatsButton.setOnClickListener (this); ExitButton View = ViewById (R.id.exit_button); ExitButton.setOnClickListener (this); Gestureoverlaywash gestures = (gesture overlayviewview) VVBIID (R.D. Gestures.addOnGesturePerformedListener (this); } Public Zero (Gestures overlay overlay, gesture gesture) on Gesture Object {ArrayList & lt; Prediction & gt; Prediction = mLibrary.recognize (hint); // We want at least one prediction (predictions.size ()> 0) {forecast prediction = predictions.get (0); // If we predicted (prediction.score> 1.0) // // gesture Toast Make text (this, prediction.Nname, toast. LNNGHARAR), at least some of you want self-confidence. Show (); // user has taken the symbol for PLAY (prediction.name.equals ("Play")) {myTTS.shutdown (); // Connect game to game // user has marked symbols for instructions} and if (prediction.name.equals ("instructions")) {myTTS.shutdown (); Beginners (new intent (this, instructions square)); // user is making symbol for MODE} and if (prediction.name.equals ("mode")) {myTTS.shutdown (); StartActivity (new intent (this, Mode.class)); // user drew icons to QUIT} and {end (); }}}} @ Override Public Wide Onclick Onclick (see V) {switch (v.getId ()} {case R.ID.instructions_button: initialization (new intent (this, instruction class)); break; Case R.id.mode_button: startActivity (new intent (this, Mode.class)); break; Case R.id.exit_button: finish (); break; }}
Any suggestions would be appreciated!
If I understand correctly, you want to click on a single view and do both gesture work , I'm not sure how to achieve this, however, we can see the invisible view behind the button to handle the gesture and in the normal way, the button button at the top can handle the event.
The default calculator application uses this approach to swap between normal mode and advanced mode.
See, com.android.calculator2.PanelSwitcher - Event Event Com for Android Calculator2.EventListener - For Click Event
Hope this helps.
Comments
Post a Comment