Skip to content

Commit 0f52886

Browse files
Grid View Item Click Issue
1 parent 338bb5d commit 0f52886

File tree

5 files changed

+19
-7
lines changed

5 files changed

+19
-7
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
3+
org.eclipse.jdt.core.compiler.compliance=1.6
4+
org.eclipse.jdt.core.compiler.source=1.6

AndroidCustomGridView/project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
1212

1313
# Project target.
14-
target=android-14
14+
target=android-21

AndroidCustomGridView/res/layout/activity_main.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
android:numColumns="auto_fit"
1616
android:verticalSpacing="5dp"
1717
android:drawSelectorOnTop="true"
18-
android:stretchMode="columnWidth" >
18+
android:stretchMode="columnWidth">
1919
</GridView>
2020

2121
</RelativeLayout>

AndroidCustomGridView/res/layout/row_grid.xml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@
55
android:layout_marginTop="5dp"
66
android:orientation="vertical"
77
android:padding="5dp"
8-
android:clickable="true"
8+
android:clickable="false"
99
android:background="@drawable/grid_color_selector"
10-
android:focusable="true">
10+
android:focusable="false"
11+
>
1112

1213
<ImageView
1314
android:id="@+id/image"
1415
android:layout_width="100dp"
15-
android:layout_height="100dp" >
16+
android:layout_height="100dp"
17+
>
1618
</ImageView>
1719

1820
<TextView
@@ -21,7 +23,8 @@
2123
android:layout_height="wrap_content"
2224
android:layout_marginTop="5dp"
2325
android:gravity="center"
24-
android:textSize="12sp" >
26+
android:textSize="12sp"
27+
>
2528
</TextView>
2629

2730
</LinearLayout>

AndroidCustomGridView/src/com/javatechig/gridview/MainActivity.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
package com.javatechig.gridview;
22

33
import java.util.ArrayList;
4-
import android.os.Bundle;
4+
55
import android.app.Activity;
66
import android.content.res.TypedArray;
77
import android.graphics.Bitmap;
88
import android.graphics.BitmapFactory;
9+
import android.os.Bundle;
10+
import android.util.Log;
911
import android.view.View;
1012
import android.widget.AdapterView;
1113
import android.widget.AdapterView.OnItemClickListener;
1214
import android.widget.GridView;
1315
import android.widget.Toast;
1416

17+
18+
1519
/**
1620
*
1721
* @author javatechig {@link http://javatechig.com}
@@ -33,6 +37,7 @@ protected void onCreate(Bundle savedInstanceState) {
3337
gridView.setOnItemClickListener(new OnItemClickListener() {
3438
public void onItemClick(AdapterView<?> parent, View v,
3539
int position, long id) {
40+
Log.e("item", "clicked");
3641
Toast.makeText(MainActivity.this, position + "#Selected",
3742
Toast.LENGTH_SHORT).show();
3843
}

0 commit comments

Comments
 (0)