2017-11-01 4 views
0
klicken

Hier ist meine item.xml:Knopf innen CardView ist nicht auf itemView reagieren

<?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> 

Hier ist, wo ich OnClickListener hinzufügen innen RecyclerView Adapters onBindViewHolder itemView:

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

jedoch das Bild, Teil reagiert auf Klicken, aber Button reagiert nicht. Sie sind alle in ItemView, also, was die Reaktion des Knopfes stoppt?

+1

'android: anklickbare = "false"' in Ohrenmarke –

+0

Danke @ Rahul Kumar –

Antwort

0

ich getan habe dies bereits versucht diese

diese Schnittstelle in Ihrem Paket hinzufügen

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

} 
Verwandte Themen