2016-04-07 6 views
0

最初に私はをCardViewの中に持っています。 GridViewはデータを表示するためのものです。アイテムはクリックできません。それぞれのCardViewにはクリックイベントがあり、詳細Activityに移動します。GridViewのアイテムを完全に無効にする

私の問題は、ユーザーがGridViewをクリックすると、詳細Activityには行きません。

マイCardViewコード:

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

事前

+0

投稿してくださいいくつかのコード –

+0

アンドロイド:クリッカブル=「false」にGridViewの – Robbert

+0

おかげ@Robbertにこれを追加しようとするが、それは動作しません。 私もこの事を試してみた: アンドロイド:クリッカブル= "false" を アンドロイド:フォーカス可能= "false" を アンドロイド:touchscreenBlocksFocus = "true" を アンドロイド:focusableInTouchMode = "false" を –

答えて

0

のおかげで私の友人は、溶液で私を助けました。

カスタムGridviewを作成し、onTouchEventメソッドをオーバーライドしました。

public class CustomGridView extends GridView { 

    ... 

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