What I'm trying to do: I want the user to be able to custom gestures and name them "up","down"..etc. Then when the user runs my application, it loads up a WebView with a particular url like http://google.com. Then the user can draw the gesture he created earlier. So if he draws the "up" gesture, then another webview opens.
My problem: When I try to draw the gesture over the webview, it doesn't draw. Rather it scrolls the webview.
What have I tried: Already created a GestureOverlayView and put the WebView within that. Unfortunately, the GestureOverlayView is unable to detect the gestures as the WebView gets scrolled.
My Code:
public class WebViewCenter extends Activity implements OnGesturePerformedListener {
/** Called when the activity is first created. */
GestureLibrary mLibrary;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//WebView webview = (WebView)findViewById(R.id.WebView01);
//webview.loadUrl("http://www.google.com");
//Button btnStart = (Button)findViewById(R.id.Start);
//btnStart.setOnClickListener(this);
mLibrary = GestureLibraries.fromRawResource(this, R.raw.gestures);
GestureOverlayView gestures = (GestureOverlayView) findViewById(R.id.gestures_overlay);
gestures.addOnGesturePerformedListener(this);
WebView webview = (WebView)findViewById(R.id.WebView);
webview.getSettings().setJavaScriptEnabled(true);
webview.loadUrl("http://live.com");
}
public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) {
mLibrary.load();
ArrayList<Prediction> predictions = mLibrary.recognize(gesture);
Log.i("Default Marker", predictions.get(0).toString());
if (predictions.size() > 0) {
String action = predictions.get(0).name;
Log.i("Gesture", action);
if ("up".equals(action)) {
Log.i("Up_gesture", "Up gesture detected");
Intent int_up = 开发者_如何学运维new Intent(WebViewCenter.this, WebViewUp.class);
WebViewCenter.this.startActivity(int_up);
//return true;
//Toast.makeText(this, "Adding a contact", Toast.LENGTH_SHORT).show();
}
/*else
{
Log.i("Marker 2", "god knows what ur upto");
}*/
}
}
Any advice as to how can I separate the WebView scrolling from the gesture building?
Thanks, Pawan
精彩评论