Wednesday, 21 August 2013

Listview adapter's button can not be clicked

Listview adapter's button can not be clicked

I am using listview's adapter, my code,
<?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>
When i remove android:clickable="true", the button can be clicked, but the
RelativeLayout can not focused. How to achieve a similar effect as Google
Plus?

No comments:

Post a Comment