Gesture on ContentView

Put your problem here if it does not fit any of the other categories.

Gesture on ContentView

Postby clemich » Wed Feb 23, 2011 5:43 pm

Hi there

First of all, I apologize for my english :D

So, I've a problem with my Application, I want to Listen the Gesture of my View, but the Listener does'nt work with the ContentView... (I Expect)
I had tu put the code for the gesture in the layout files, but the ContentView isn't a element of the layout...

Some lines of code to explain my problem:

Code: Select all
public class SecondTab extends Activity implements OnGesturePerformedListener{
   private GestureLibrary mLibrary;

   @Override
   public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.tab);

      /** Pour la gesture */
      mLibrary = GestureLibraries.fromRawResource(this, R.raw.actions);
        if (!mLibrary.load()) {
           finish();
        }
        GestureOverlayView gestures = (GestureOverlayView) findViewById(R.id.gestures);
        gestures.addOnGesturePerformedListener(this);

      /** Second Tab Content */
      float[] values = new float[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};
      GraphView graphView = new GraphView(this, values,"Graphe de la date", GraphView.BAR);
      setContentView(graphView);
      Log.v("","hehehe");
      //setContentView(R.layout.tab);

   }   /** fin du OnCreate */

   /** fonction pour les gestures */
   public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) {
      ArrayList<Prediction> predictions = mLibrary.recognize(gesture);

      // We want at least one prediction
      if (predictions.size() > 0) {
         Prediction prediction = predictions.get(0);
         // We want at least some confidence in the result
         if (prediction.score > 1.0) {
            // Show the spell
            Log.v("", "" + prediction.name);
         }
      }
   }


THANKS FOR HELPING !!!
clemich
Freshman
Freshman
 
Posts: 6
Joined: Wed Feb 23, 2011 5:32 pm

Top

Re: Gesture on ContentView

Postby clemich » Thu Feb 24, 2011 11:08 am

Hi,

this is my application. I try to have actions made by the Listener of the second Tab...

I share my file because it's probably easier for you :P
http://docs.clementhallet.be/probleme_emars.zip

THANK YOU
clemich
Freshman
Freshman
 
Posts: 6
Joined: Wed Feb 23, 2011 5:32 pm

Re: Gesture on ContentView

Postby clemich » Thu Feb 24, 2011 1:05 pm

Ok I fixed my problem on putting this line

Code: Select all
<android.gesture.GestureOverlayView
      android:id="@+id/gestures" android:layout_width="fill_parent"
      android:layout_height="fill_parent" android:layout_weight="1.0"
      android:eventsInterceptionEnabled="true" android:gestureStrokeType="single"
      android:gestureColor="#00FFFFFF" />


just before the linear layout of the XML wich is useb by the Tab's :D
clemich
Freshman
Freshman
 
Posts: 6
Joined: Wed Feb 23, 2011 5:32 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 13 guests