Getting a gestureoverlayview
Posted
by
Codejoy
on Stack Overflow
See other posts from Stack Overflow
or by Codejoy
Published on 2010-04-27T20:48:17Z
Indexed on
2012/09/30
3:38 UTC
Read the original article
Hit count: 219
I have been using some nice tutorials on drawing graphics on my android. I wanted to also add in the cool gesture demo found here:
http://developer.android.com/resources/articles/gestures.html
That takes these lines of code:
GestureOverlayView gestures = (GestureOverlayView) findViewById(R.id.gestures);
gestures.addOnGesturePerformedListener(this);
This is fine and dandy yet I realize in my demo i'm trying to build using code from "Playing with Graphics in Android". The demos make sense, everything makes sense but I found out by using:
setContentView(new Panel(this));
as is required by the Playing With Graphics tutorials, then the findViewById seems to no longer be valid and returns null. At first I was about to post a stupider question as to why this is happening, a quick test of playing with the setContentView made me realize the cause of findViewById returning null, I just do not know how to remedy this issue. Whats the key I am missing here? I realize that the new Panel is doinking some reference up but I am not sure how to make the connection here.
The: R.id.gestures is defined right int he main.xml as: (just like the tutorial)
<android.gesture.GestureOverlayView
android:id="@+id/gestures"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1.0" />
So I did confirm the
setContentView(new Panel(this))
is causing the issue. So I know the issue is that I have to figure out how to add the android.gesture.GestureOverlayView to the panel class somehow, I am just not sure how to go about this.
After fighting with this I generally know what I need to do just now how to do it. I think I need either the equivalent of creating a panel in that main.xml OR figuring out how to build whats in main.xml for the gestures in code. I am close because I did this: GestureOverlayView gestures = new GestureOverlayView(this);
which gets me a non null gestures now, unfortunately since I am not telling it to fill Parent anywhere I don't think its really showing up, so I am trying hard to figure out layout pa rams. Am I even on the right track?
© Stack Overflow or respective owner