同时触摸2个不同的按钮触发另一个按钮(中间一个)

时间:2015-01-31 07:35:56

标签: android android-linearlayout multi-touch

我在LinearLayout 中有 5个按钮。

我的问题是同时触摸 最左边&最右边的按钮会触发中间按钮。

我试过了

android:splitMotionEvents="false"
android:windowEnableSplitTouch="false"

,遗憾的是没有任何作用。我该怎么办 ? 。

我的XML代码段是

     <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:splitMotionEvents="false"
        android:windowEnableSplitTouch="false" >

        <Button
            android:id="@+id/someText1"
            style="@style/ButtonStyle"
            android:layout_marginRight="10dp"
            android:onClick="someText1"
            android:text="someText1" />

        <Button
            android:id="@+id/someText2"
            style="@style/ButtonStyle"
            android:layout_marginRight="10dp"
            android:enabled="false"
            android:onClick="someText2"
            android:text="someText2" />

        <Button
            android:id="@+id/someText3"
            style="@style/ButtonStyle"
            android:layout_marginRight="10dp"
            android:onClick="someText3"
            android:text="someText3" />
        <Button
            android:id="@+id/someText4"
            style="@style/ButtonStyle"
            android:layout_marginRight="10dp"
            android:onClick="someText4"
            android:text="someText4" />

        <Button
            android:id="@+id/someText5"
            style="@style/ButtonStyle"
            android:layout_marginRight="10dp"
            android:onClick="someText5"
            android:text="someText5" />

        <Button
            android:id="@+id/someText6"
            style="@style/ButtonStyle"
            android:onClick="someText6"
            android:text="someText6" />
    </LinearLayout>

如果没有直接的解决方案,是否有任何解决方案

注意:我正在使用Android JellyBean4.1.2

提前多多感谢。

2 个答案:

答案 0 :(得分:0)

我不知道它是否有效

只需尝试在Java代码中动态设置OnClick侦听器

喜欢

button1.setOnCllickListener(onclicklistenerobject);

答案 1 :(得分:0)

我认为不可能一次推几个股票按钮(android.widget.button)。

您可以实现自己的按钮,也可以检测父窗口小部件上的多点触控,并检查按钮上是否有触摸位置。