我是 android 开发的新手,我尝试为 Activity 实现滑动(使用 Ontouch)并为 Activity 中的按钮实现点击事件。如果我在按钮顶部滑动,则不会生成滑动事件。
如果我为按钮添加滑动,则不会生成按钮的 onclick 事件。
我该怎么办,来解决这个问题。
如有任何澄清,请询问我。
布局代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/main_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/default_2x"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".LearnUpperCaseActivity" >
    <LinearLayout
        android:id="@+id/content_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >
        <TextView
            android:id="@+id/title"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="center_horizontal"
            android:text="@string/learn_uppercase"
            android:textAppearance="?android:attr/textAppearanceLarge" />
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="11"
            android:background="@drawable/main_area_blue_2x" >
            <TextView
                android:id="@+id/question"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:gravity="center"
                android:text="@string/hard_coded_char" />
        </RelativeLayout>
        <TextView
            android:id="@+id/instruction"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="@string/tab_below" />
        <RelativeLayout
            android:id="@+id/button_container"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="9"
            android:padding="3dp" >
            <LinearLayout
                android:id="@+id/row1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal" >
                <Button
                    android:id="@+id/button1"
                    style="@style/UpperCaseButton"
                    android:layout_width="wrap_content"
                    android:layout_height="50dp"
                    android:layout_margin="3dp"
                    android:layout_weight="1"
                    android:background="@drawable/blue_button"
                    android:onClick="button1Pressed"
                    android:text="@string/hard_coded_char" >
                </Button>
                <Button
                    android:id="@+id/button2"
                    style="@style/UpperCaseButton"
                    android:layout_width="wrap_content"
                    android:layout_height="50dp"
                    android:layout_margin="3dp"
                    android:layout_weight="1"
                    android:background="@drawable/brown_button_2x"
                    android:onClick="button2Pressed"
                    android:text="@string/hard_coded_char" >
                </Button>
                <Button
                    android:id="@+id/button3"
                    style="@style/UpperCaseButton"
                    android:layout_width="wrap_content"
                    android:layout_height="50dp"
                    android:layout_margin="3dp"
                    android:layout_weight="1"
                    android:background="@drawable/dark_green_2x"
                    android:onClick="button3Pressed"
                    android:text="@string/hard_coded_char" >
                </Button>
            </LinearLayout>
            <LinearLayout
                android:id="@+id/row2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/row1"
                android:orientation="horizontal" >
                <Button
                    android:id="@+id/button4"
                    style="@style/UpperCaseButton"
                    android:layout_width="wrap_content"
                    android:layout_height="50dp"
                    android:layout_margin="3dp"
                    android:layout_weight="1"
                    android:background="@drawable/fluora_button_2x"
                    android:onClick="button4Pressed"
                    android:text="@string/hard_coded_char" >
                </Button>
                <Button
                    android:id="@+id/button5"
                    style="@style/UpperCaseButton"
                    android:layout_width="wrap_content"
                    android:layout_height="50dp"
                    android:layout_margin="3dp"
                    android:layout_weight="1"
                    android:background="@drawable/green_button_2x"
                    android:onClick="button5Pressed"
                    android:text="@string/hard_coded_char" >
                </Button>
                <Button
                    android:id="@+id/button6"
                    style="@style/UpperCaseButton"
                    android:layout_width="wrap_content"
                    android:layout_height="50dp"
                    android:layout_margin="3dp"
                    android:layout_weight="1"
                    android:background="@drawable/maroon_2x"
                    android:onClick="button6Pressed"
                    android:text="@string/hard_coded_char" >
                </Button>
            </LinearLayout>
            <LinearLayout
                android:id="@+id/row3"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/row2"
                android:orientation="horizontal" >
                <Button
                    android:id="@+id/button7"
                    style="@style/UpperCaseButton"
                    android:layout_width="wrap_content"
                    android:layout_height="50dp"
                    android:layout_margin="3dp"
                    android:layout_weight="1"
                    android:background="@drawable/yellow_button_2x"
                    android:onClick="button7Pressed"
                    android:text="@string/hard_coded_char" >
                </Button>
                <Button
                    android:id="@+id/button8"
                    style="@style/UpperCaseButton"
                    android:layout_width="wrap_content"
                    android:layout_height="50dp"
                    android:layout_margin="3dp"
                    android:layout_weight="1"
                    android:background="@drawable/purple_button_2x"
                    android:onClick="button8Pressed"
                    android:text="@string/hard_coded_char" >
                </Button>
                <Button
                    android:id="@+id/button9"
                    style="@style/UpperCaseButton"
                    android:layout_width="wrap_content"
                    android:layout_height="50dp"
                    android:layout_margin="3dp"
                    android:layout_weight="1"
                    android:background="@drawable/pink_button_2x"
                    android:onClick="button9Pressed"
                    android:text="@string/hard_coded_char" >
                </Button>
            </LinearLayout>
            <LinearLayout
                android:id="@+id/row4"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/row3"
                android:gravity="center"
                android:orientation="horizontal" >
                <Button
                    android:id="@+id/home"
                    style="@style/UpperCaseButton"
                    android:layout_width="150dp"
                    android:layout_height="30dp"
                    android:layout_margin="3dp"
                    android:background="@drawable/blue_long_button_2x"
                    android:onClick="home"
                    android:text="@string/home" >
                </Button>
            </LinearLayout>
        </RelativeLayout>
    </LinearLayout>
</RelativeLayout>
请参阅此链接中的图像。https://sites.google.com/site/temptemptemp123tempqwe/doubt.jpg?attredirects=0
请帮我解决这个问题。
问候,班纳特。