我有一个带有两个视图的LinearLayout,一个是ImageView,顶部是一个Button。 (请参见下图)
但是,当我将OnClickListener添加到按钮和ImageView时,只有在ImageView中设置的那个似乎起作用。
注意:此视图是ViewPager内部片段的一部分。
我不知道如何使两个听众都能正常工作!
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" >
<ImageView
android:id="@+id/my_photo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center" />
<Button
android:text="BACK"
android:id="@+id/my_button"
android:layout_height="wrap_content"
android:padding="@dimen/default_padding"
android:layout_width="wrap_content"
android:layout_gravity="start"/>
</FrameLayout>
...
</LinearLayout>