0
我跟着this教程在我的Android應用程序中創建了一個GestureOverlayView。我的主視圖中有一個顏色選擇器,我已經添加了手勢疊加層。現在,疊加層可以正常工作,但當疊加層位於頂層時,不會觸發顏色選擇器的顏色變化事件。這是活動的代碼。GestureOverlayView隱藏子視圖的事件
public class LightingActivity extends Activity implements OnColorChangedListener, OnGesturePerformedListener {
private ColorPicker picker;
private GestureLibrary gestureLib;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_lighting);
picker = (ColorPicker) findViewById(R.id.picker);
//Register the event handler for color changes
picker.setOnColorChangedListener(this);
GestureOverlayView gestureOverlayView = new GestureOverlayView(this);
View inflate = getLayoutInflater().inflate(R.layout.activity_lighting, null);
gestureOverlayView.addView(inflate);
gestureOverlayView.addOnGesturePerformedListener(this);
gestureLib = GestureLibraries.fromRawResource(this, R.raw.gestures);
if (!gestureLib.load()) {
finish();
}
setContentView(gestureOverlayView);
}
@Override
public void onColorChanged(int color) {
Toast.makeText(this, color, Toast.LENGTH_LONG).show();
}
@Override
public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) {
ArrayList<Prediction> predictions = gestureLib.recognize(gesture);
for (Prediction prediction : predictions) {
if (prediction.score > 1.0) {
Toast.makeText(this, prediction.name, Toast.LENGTH_SHORT)
.show();
}
}
}
}
我想要手勢疊加,同時仍然能夠觸發顏色選擇器視圖的onColorChanged事件。任何幫助將是偉大的!提前致謝。
沒人?認真? –