在这里的好人们的帮助下,我终于得到了我的小游戏面板(这是一个surfaceview类)并运行了GestureOverlayView。通过使用addView,我终于能够添加GestureOverlayView并使其正常工作,麻烦的是调用它:
/** create the login form */
private ViewGroup _createGameStuffs() {
GestureOverlayView gestures = new GestureOverlayView(this);
gestures.setOrientation(gestures.ORIENTATION_VERTICAL);
gestures.setEventsInterceptionEnabled(true);
gestures.setGestureStrokeType(gestures.GESTURE_STROKE_TYPE_MULTIPLE);
gestures.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT));
//GestureOverlayView gestures = (GestureOverlayView) findViewById(R.id.gestures);
gestures.addOnGesturePerformedListener(this);
Panel p = new Panel(this); //my game view
panel.addView(p,0); //add it to the group
panel.addView(gestures,1); //add the gestureoverlayview i made to the group
return panel;
}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
mLibrary = GestureLibraries.fromRawResource(this, R.raw.myspells);
// create the panel to enclose everything
View mainPanel = _createGameStuffs();
// show the panel on the screen
setContentView(mainPanel);
//setContentView(p);
}
取决于我给哪个索引进行优先考虑的索引。这让我相信我的游戏面板必须作为子视图添加到GestureOverlayView,这是正确的吗?如果是这样,我如何获得GestureOverlayView的子视图?或者是相反,GestureOverlayView成为我主视图的孩子?