現在4択のクイズアプリを作成しているが、
ボタンを同時(Androidでは多少の誤差でも判別するため、厳密には違う)に2つ押された際に、意図しない挙動をしていることが分かった。
その事象は、
「その問題の判定には問題なかったが、次の問題の判定において、後に押された方の解答が適用される」
といったものだった。
アプリ開発初心者のため、ボタンが同時に押されることまで頭がまわらなかったので、
とりあえず検索した。
すると、簡単に制御できる方法があったので以下に記す。
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:splitMotionEvents="false">
<Button
android:layout_width="100dp"
android:layout_height="100dp"
android:id="@+id/Button1" />
<Button
android:layout_width="100dp"
android:layout_height="100dp"
android:id="@+id/Button2" />
</RelativeLayout>
android:splitMotionEvents="false"の部分である。
ただし、同時に押されるであろうボタン群を、
android:splitMotionEvents="false"を適用したレイアウトに配置していないと効果がないようだ。
以上です。