2016-04-07 30 views
0

İlk önce CardView'un içinde bir GridView var. GridView sadece verileri göstermek içindir, Öğeler tıklanabilir değildir. Ve her CardView, Activity detayına gitmek için bir tıklama etkinliğine sahiptir.GridView Öğesini Devre Dışı Bırakma tam olarak tıklayın

Sorunum, kullanıcı GridView numaralı telefonu tıklattığında, Activity ayrıntıya gitmiyor.

Benim CardView kodu:

<android.support.v7.widget.CardView 
android:id="@+id/card_view_geo" 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:orientation="vertical" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:layout_marginLeft="@dimen/activity_vertical_margin" 
android:layout_marginRight="@dimen/activity_vertical_margin" 
android:layout_marginTop="@dimen/horizontal_space_medium" 
android:layout_marginBottom="@dimen/horizontal_space_small" 
android:background="?attr/selectableItemBackground" 
android:foreground="?android:attr/selectableItemBackground" 
android:clickable="true" 
android:layout_gravity="center" 
cardUseCompatPadding="true" 
cardElevation="3dp" > 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:paddingTop="@dimen/vertical_space_small" 
    android:paddingBottom="@dimen/vertical_space_medium" 
    android:paddingLeft="@dimen/horizontal_space_medium" 
    android:paddingRight="@dimen/horizontal_space_medium" 
    android:orientation="vertical"> 

    <TextView 
     android:id="@+id/text_geo_name" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="@dimen/vertical_space_small" 
     android:singleLine="true" 
     android:textSize="@dimen/title_text_size" 
     android:text="My Geo"/> 

    <br.com.hbsis.indicadores.util.view.WrapContentGridView xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/grid_view_indicators" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:columnWidth="@dimen/grid_view_column_width" 
     android:numColumns="auto_fit" 
     android:verticalSpacing="@dimen/grid_view_spacing" 
     android:horizontalSpacing="@dimen/grid_view_spacing" 
     android:stretchMode="columnWidth" 
     android:gravity="center"/> 

</LinearLayout> 

Şimdiden teşekkürler

+0

gönderin bazı kod –

+0

android: tıklanabilir = "false" GRIDVIEW – Robbert

+0

sayesinde @Robbert bu eklemeyi deneyin, ama çalışmıyor. android: tıklanabilir = "false" android: odaklanabilir = "false" android: Ben de bu işler denedim touchscreenBlocksFocus = "true" android: focusableInTouchMode = "false" –

cevap

0

yılında bir arkadaşım solüsyonu ile bana yardımcı oldu.

Özel bir Gridview oluşturduk ve onTouchEvent yöntemini geçersiz kıldık.

public class CustomGridView extends GridView { 

    ... 

    @Override 
    public boolean onTouchEvent(MotionEvent ev) { 
     return false; 
    } 
}