0

okay guys, i have layout like this

<ScrollView
android:id="@+id/scrollViewTree"
android:layout_width="match_parent"
android:layout_height="wrap_content" >

<include
android:id="@+id/layoutGallery"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
layout="@layout/layout_gallery_obstruction" >
</include>

</ScrollView>

and this is the *layout_gallery_obstruction*

?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <TextView
        android:id="@+id/textViewGalleryObs"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/buttonGalleryObs"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:text="@string/obstruction_title_gallery" />

    <Button
        android:id="@+id/buttonGalleryObs"
        android:layout_width="100dp"
        android:layout_height="35dp"
        android:layout_marginLeft="30dp"
        android:layout_toRightOf="@+id/textViewGalleryObs"
        android:text="@string/obstruction_gallery_add"
        android:textSize="12sp" />

    <GridView
        android:id="@+id/gridViewGalleryObs"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignLeft="@+id/textViewGalleryObs"
        android:layout_below="@+id/buttonGalleryObs"
        android:columnWidth="90dp"
        android:gravity="center"
        android:horizontalSpacing="5dp"
        android:numColumns="4"
        android:stretchMode="columnWidth"
        android:verticalSpacing="5dp" >
    </GridView>

</RelativeLayout>

i using custom adapter for my gridview and this is the layout for the cell

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <ImageButton
        android:id="@+id/imageButton1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:background="@android:color/transparent"
        android:contentDescription="@string/app_name" />

</RelativeLayout>

okay my problem is, i can't scroll my gridview , and i can't click the item on my gridview . anybody know how to fix this ? thanks in adv . :)

Khairil Ushan
  • 2,358
  • 5
  • 26
  • 29
  • 1
    As kettu says, I would put a GridView into a ScroolView, too. Currently you have just an TextView and Button above the Gridview -> I would set them fix above the GridView. But you can try the solution of @Moisés Olmedo in this post http://stackoverflow.com/questions/6210895/listview-inside-scrollview-is-not-scrolling-on-android. Thats really simple and nice. Hope this will help you :) – owe Aug 13 '13 at 06:00
  • ow great , i found the solution in this comment > http://stackoverflow.com/questions/6210895/listview-inside-scrollview-is-not-scrolling-on-android#comment18942746_6211286 yeah, i have to make a custom scrollview (extend from scrollview class).. :) thanks for give me that link .. :) – Khairil Ushan Aug 13 '13 at 06:55

3 Answers3

9

Enable your GridView Property as

android:nestedScrollingEnabled="true".

Droid_Dev
  • 1,162
  • 1
  • 8
  • 25
0

no need to put gridview inside scrollview and for item click I hope this help you

Community
  • 1
  • 1
Ketan Ahir
  • 6,678
  • 1
  • 23
  • 45
  • in my case i think i have to put it on scrollview, because there are a lot of component in this layout (not only the gridview). there're edittexts, spinner, textview, etc. so i think i've to use scrollview in this case . – Khairil Ushan Aug 13 '13 at 05:51
  • 1
    what about item click ? Did it work ? http://stackoverflow.com/questions/18142646/view-from-back-does-not-respond-to-click-android/18146003?noredirect=1#comment26643023_18146003 – Ketan Ahir Aug 13 '13 at 05:58
  • yes , i've done with the item click, i just found that in gridview we should not put a clickable object . so i just change the imagebutton with a imageview . – Khairil Ushan Aug 13 '13 at 06:20
0

okey, i've done with my problem . :) thanks for all of you who have show me the clue . :D

first for scrolling gridview inside scrollview, basically we shouldn't put a gridview inside a scrollview, but it doesn't mean we can't do that. we just need to use a custom scrollview,i found it from this comment > https://stackoverflow.com/a/11554684/2496348

and about the gridview onItemClickListener, we can not put a clickable object inside a gridview, so i just change the imagebutton to be imageview.

that's it ! thanks :)

Community
  • 1
  • 1
Khairil Ushan
  • 2,358
  • 5
  • 26
  • 29