2017-11-01 13 views
0

をクリックitemViewして反応していないことは、私のitem.xmlです:私はRecyclerViewアダプタのonBindViewHolder内itemViewにonClickListener追加のはここボタンはここ

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginLeft="@dimen/card_side_margin" 
    android:layout_marginRight="@dimen/card_side_margin" 
    app:cardCornerRadius="16dp" 
    app:cardElevation="8dp" 
    app:cardPreventCornerOverlap="false" 
    app:cardUseCompatPadding="true"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical"> 

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

      <com.makeramen.roundedimageview.RoundedImageView 
       android:id="@+id/image" 
       android:layout_width="match_parent" 
       android:layout_height="100dp" 
       android:scaleType="centerCrop" 
       app:riv_corner_radius_top_left="16dp" 
       app:riv_corner_radius_top_right="16dp" 
       tools:src="@drawable/anne_kalbi" /> 

      <View 
       android:layout_width="match_parent" 
       android:layout_height="100dp" 
       android:background="@drawable/top_rounded_rect" /> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginBottom="16dp" 
       android:layout_marginLeft="16dp" 
       android:layout_marginTop="16dp" 
       android:orientation="vertical"> 

       <TextView 
        android:id="@+id/title" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:padding="5dp" 
        android:textColor="@color/white" 
        android:textSize="@dimen/item_poem_title_size" 
        tools:text="Anne Kalbi" /> 

       <TextView 
        android:id="@+id/poet" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:padding="5dp" 
        android:textColor="@color/white" 
        android:textSize="@dimen/item_poem_poet_size" 
        tools:text="Şair: Mehmet Çağan" /> 

      </LinearLayout> 

     </FrameLayout> 


     <Button 
      android:id="@+id/listenBtn" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="@drawable/bottom_rounded_rect" 
      android:gravity="center" 
      android:text="@string/listen" 
      android:textColor="#fff" /> 


    </LinearLayout> 

</android.support.v7.widget.CardView> 

は次のとおりです。

holder.itemView.setOnClickListener(new View.OnClickListener() { 
    @Override 
    public void onClick(View v) { 
     if (itemListener != null) 
      itemListener.onItemClicked(item, position); 
     } 
    }); 
} 

ただし、画像部分はクリックに反応していますが、ボタンは反応しません。それらはすべてitemView内にありますので、ボタンの反応は何ですか?

+1

'アンドロイドにこのインタフェースを追加し、この

を試しすでにこれを行っている:クリック可能なボタンのタグに' = "false" を –

+0

おかげで、@ラフルクマール –

答えて

0

私はあなたのパッケージ

public interface ItemClickListener { 
    void onClick(View view, int position, boolean isLongClick); 

} 
関連する問題