1

私は次のXMLファイルを持っています

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/welcome_bg" >

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ImageView
            android:id="@+id/arrowLeft"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical|left"
            android:layout_marginLeft="10dp"
            android:clickable="true"
            android:contentDescription="@string/arrow_left"
            android:focusable="true"
            android:src="@drawable/arrow_left"
            android:visibility="invisible" />

        <ImageView
            android:id="@+id/arrowRight"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical|right"
            android:layout_marginRight="10dp"
            android:clickable="true"
            android:contentDescription="@string/arrow_right"
            android:focusable="true"
            android:src="@drawable/arrow_right" />

        <android.support.v4.view.ViewPager
            android:id="@+id/tutorialViewPager"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </FrameLayout>

</RelativeLayout>

私の問題は、ユーザーが左矢印または右矢印をクリックすると、ページャーが反転するはずですが、左矢印または右矢印のImageViewでクリックイベントを取得できないことです。矢印をクリックするとイベントを取得できません。両方の矢印にonClickListenersを設定しましたが、呼び出されることはありません。誰かがこれを手伝ってくれませんか?

4

1 に答える 1

1

私はそれを考え出した。と を使用する必要がrightArrow.bringToFront()ありleftArrow.bringToFront()ました。これにより、ボタンが前面に表示され、クリックイベントを取得できました。

于 2012-09-05T18:04:46.207 に答える