From 0f52886baf620ae325b4fa7362783b661ad2e02d Mon Sep 17 00:00:00 2001 From: yogeshmadaan100 Date: Wed, 1 Apr 2015 21:21:29 +0530 Subject: [PATCH 1/2] Grid View Item Click Issue --- .../.settings/org.eclipse.jdt.core.prefs | 4 ++++ AndroidCustomGridView/project.properties | 2 +- AndroidCustomGridView/res/layout/activity_main.xml | 2 +- AndroidCustomGridView/res/layout/row_grid.xml | 11 +++++++---- .../src/com/javatechig/gridview/MainActivity.java | 7 ++++++- 5 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 AndroidCustomGridView/.settings/org.eclipse.jdt.core.prefs diff --git a/AndroidCustomGridView/.settings/org.eclipse.jdt.core.prefs b/AndroidCustomGridView/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..b080d2d --- /dev/null +++ b/AndroidCustomGridView/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/AndroidCustomGridView/project.properties b/AndroidCustomGridView/project.properties index 8937e94..6e18427 100644 --- a/AndroidCustomGridView/project.properties +++ b/AndroidCustomGridView/project.properties @@ -11,4 +11,4 @@ #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt # Project target. -target=android-14 +target=android-21 diff --git a/AndroidCustomGridView/res/layout/activity_main.xml b/AndroidCustomGridView/res/layout/activity_main.xml index c5519f9..1410c1f 100644 --- a/AndroidCustomGridView/res/layout/activity_main.xml +++ b/AndroidCustomGridView/res/layout/activity_main.xml @@ -15,7 +15,7 @@ android:numColumns="auto_fit" android:verticalSpacing="5dp" android:drawSelectorOnTop="true" - android:stretchMode="columnWidth" > + android:stretchMode="columnWidth"> \ No newline at end of file diff --git a/AndroidCustomGridView/res/layout/row_grid.xml b/AndroidCustomGridView/res/layout/row_grid.xml index f9c1969..5ad98ec 100644 --- a/AndroidCustomGridView/res/layout/row_grid.xml +++ b/AndroidCustomGridView/res/layout/row_grid.xml @@ -5,14 +5,16 @@ android:layout_marginTop="5dp" android:orientation="vertical" android:padding="5dp" - android:clickable="true" + android:clickable="false" android:background="@drawable/grid_color_selector" - android:focusable="true"> + android:focusable="false" + > + android:layout_height="100dp" + > + android:textSize="12sp" + > \ No newline at end of file diff --git a/AndroidCustomGridView/src/com/javatechig/gridview/MainActivity.java b/AndroidCustomGridView/src/com/javatechig/gridview/MainActivity.java index 1a453dc..6e2845a 100644 --- a/AndroidCustomGridView/src/com/javatechig/gridview/MainActivity.java +++ b/AndroidCustomGridView/src/com/javatechig/gridview/MainActivity.java @@ -1,17 +1,21 @@ package com.javatechig.gridview; import java.util.ArrayList; -import android.os.Bundle; + import android.app.Activity; import android.content.res.TypedArray; import android.graphics.Bitmap; import android.graphics.BitmapFactory; +import android.os.Bundle; +import android.util.Log; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.GridView; import android.widget.Toast; + + /** * * @author javatechig {@link http://javatechig.com} @@ -33,6 +37,7 @@ protected void onCreate(Bundle savedInstanceState) { gridView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView parent, View v, int position, long id) { + Log.e("item", "clicked"); Toast.makeText(MainActivity.this, position + "#Selected", Toast.LENGTH_SHORT).show(); } From 9e43c67e33be8ad27ecdf2be0dc4295339f36b98 Mon Sep 17 00:00:00 2001 From: yogeshmadaan100 Date: Wed, 1 Apr 2015 21:24:07 +0530 Subject: [PATCH 2/2] Grid View Item Click Issue --- AndroidCustomGridView/res/layout/activity_main.xml | 2 +- AndroidCustomGridView/res/layout/row_grid.xml | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/AndroidCustomGridView/res/layout/activity_main.xml b/AndroidCustomGridView/res/layout/activity_main.xml index 1410c1f..c5519f9 100644 --- a/AndroidCustomGridView/res/layout/activity_main.xml +++ b/AndroidCustomGridView/res/layout/activity_main.xml @@ -15,7 +15,7 @@ android:numColumns="auto_fit" android:verticalSpacing="5dp" android:drawSelectorOnTop="true" - android:stretchMode="columnWidth"> + android:stretchMode="columnWidth" > \ No newline at end of file diff --git a/AndroidCustomGridView/res/layout/row_grid.xml b/AndroidCustomGridView/res/layout/row_grid.xml index 5ad98ec..461ceee 100644 --- a/AndroidCustomGridView/res/layout/row_grid.xml +++ b/AndroidCustomGridView/res/layout/row_grid.xml @@ -7,14 +7,12 @@ android:padding="5dp" android:clickable="false" android:background="@drawable/grid_color_selector" - android:focusable="false" - > + android:focusable="false"> + android:layout_height="100dp" > + android:textSize="12sp" > \ No newline at end of file