我使用ListView的適配器,我的代碼,列表視圖適配器的按鈕不能點擊
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:padding="10dp"
android:background="@android:color/darker_gray"
android:orientation="vertical" >
<TextView
android:id="@+id/tv_position"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/white"
android:text="position1"
android:textSize="20sp"
/>
<Button
android:id="@+id/btn_like"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
/>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:background="@drawable/selector_translate_blue"
android:clickable="true" //Add this is to allow this to get focus, but the button can not be clicked.
>
</RelativeLayout>
</FrameLayout>
當我刪除的android:點擊=「true」,則可以單擊該按鈕,但RelativeLayout的無法聚焦。 如何實現與Google Plus相似的效果?
UPDATE 現在只有RelativeLayout可以被點擊。 我的意思是如何使Button也可以被點擊? 不要同時點擊它們兩個。
Thanks.No use ah ...,我希望Button和RelativeLayout都可以被點擊。 – fatsoon
@tenpage看起來您的'LinearLayout'與您的'RelativeLayout'重疊,因此您不能觸及'RelativeLayout',將'LinearLayout'的'onClick'事件傳遞到'RelativeLayout'。查看我的更新。乾杯! – user2652394
對不起,我的表情錯誤。 – fatsoon