2016-04-07 22 views
0

Zuerst habe ich eine GridView innerhalb einer CardView. Die GridView dient nur zum Anzeigen von Daten, Elemente sind nicht anklickbar. Und jedes CardView hat ein Klickereignis, um zum Detail Activity zu gehen.Deaktivieren Sie GridView Element klicken Sie vollständig

Mein Problem ist, dass wenn Benutzer auf GridView klickt, geht es nicht zum Detail Activity.

Mein CardView Code:

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

Vielen Dank im Voraus

+0

bitte posten einige Code –

+0

android: anklickbare = „false“ versuchen, diese – Robbert

+0

Dank @Robbert, auf die Gridview hinzuzufügen, aber es funktioniert nicht. Ich habe diese Dinge auch versucht: android: anklickbare = "false" android: fokussierbarem = "false" android: touchscreenBlocksFocus = "true" android: focusableInTouchMode = "false" –

Antwort

0

ein Freund von mir hat mir geholfen, mit der Lösung.

Wir haben eine benutzerdefinierte Gridview erstellt und onTouchEvent Methode übersteuert.

public class CustomGridView extends GridView { 

    ... 

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