好吧,所以,我有一个视图,其中包含两个按钮。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/linear"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<Button
android:id="@+id/botonno"
android:layout_width="130dp"
android:layout_height="match_parent"
android:background="@drawable/red_button"
android:layout_weight="0.5"
android:text="NON"
android:textColor="#FFF"
android:textSize="30sp"
android:textStyle="bold" />
<Button
android:id="@+id/botonoui"
android:layout_width="130dp"
android:layout_height="match_parent"
android:background="@drawable/green_buton"
android:layout_weight="0.5"
android:text="OUI"
android:textColor="#FFF"
android:textSize="30sp"
android:textStyle="bold" />
我需要的是用户会同时触摸BOTH按钮,但是我需要检测他/她是否在“ouiButton”或“nonButton”上滚动。
我尝试过使用onGestureListener,但它没有检测到任何内容.....任何人都有任何想法?
非常感谢!
答案 0 :(得分:0)
尝试:
Button ouiButton = (Button) view.findByViewId(R.id.botonoui);
ouiButton.didTouchFocusSelect();
或
ouiButton.setOnGenericMotionListener(new OnGenericMotionListener() {
//Insert code here
});