2011-03-15 17 views
0

是否有任何方法可以從使用手勢構建器創建的手勢庫中獲取手勢ID列表,然後將它們鏈接到存儲在數組中的圖像。 使用圖像添加到手勢疊加視圖,以便顯示。如何獲取手勢ID並鏈接到陣列中的圖像

我想將每個手勢鏈接到圖像,因此需要某種類型的ID或名稱。我已經看過樣本和其他在線材料avaialbe手勢,並沒有關於這個問題的信息。

任何幫助在這個問題將不勝感激。

例子:

//Link the images to the gesture ids, so when a user draws an "a", 
//it is linked to the gesture "a" 
if (sStore.load()) 
{ 

     for (String name : sStore.getGestureEntries()) 
    { 
     //Stores the gesture and its name into Gesture gesture 
    for (Gesture gesture : sStore.getGestures(name)) 
    { 
     gesture.getID(); 
      //link IDs to image_array[i] 

     } 
    } 
} 


//match the image and the gesture, after a touch event. 
if (predictions.size() > 0) 
{ 
Prediction prediction = predictions.get(0); 
if(prediction.score > 1.0) 
{ 
     if(prediction.best_score == Current_Image) 
     { 
      Correct(); 
      Next_image(); 
     } 
    } 
} 
+0

抱歉需要更多信息。你能鏈接到手勢庫的API嗎? – Blundell 2011-03-15 15:51:36

+0

以下是鏈接信息: http://developer.android.com/reference/android/gesture/package-summary.html http://developer.android.com/resources/articles/gestures.html – Navigatron 2011-04-06 20:21:49

回答

0
GestureLibrary store = GestureLibraries.fromFile("/the/gesture/file"); 
if (store.load()){ 
    for (String name : store.getGestureEntries()){ 
     // access each gesture name/id 
    } 
} 

有趣的是如何做到這樣的事情完整的例子就是你的Android SDK的樣本目錄中。

+0

我沒有看到Cristian,因爲它在GestureBuilderActivity.java文件中。感謝您的信息! – Navigatron 2011-03-15 17:07:56

0

如果您爲每個手勢創建了單獨的手勢庫,那麼每個庫都可以放入一個數組中。這個手勢庫數組可以通過其索引與一組圖像進行匹配。選擇圖像時,請確保已加載相應的手勢庫。