1

I need to scroll a list of custom grid horizontally. I have already implement a grid and a horizontal scrollable list individually. But when I combined both the codes it doesnt work. Can someone please suggest any way to do this? Appreciate your help.

Thanks in Advance.

Here is my xml:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center"
    >

    <HorizontalScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content" 
        android:scrollbars="none">
        <LinearLayout
            android:id="@+id/mygallery"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            />
    </HorizontalScrollView>

</LinearLayout>

Here is my code:

 LinearLayout myGallery = (LinearLayout)findViewById(R.id.mygallery);

        for(int i=0; i<4 ; i++)
        {
 LayoutInflater inflater =  getLayoutInflater();    
        LinearLayout layout=(LinearLayout) inflater.inflate(R.layout.scroll_view_item, null);
            GridView gridView = (GridView)layout.findViewById(R.id.gridview);
            gridView.setAdapter(new MyAdapter(this));
         myGallery.addView(layout);
        }

        myGallery.setHorizontalScrollBarEnabled(false);
        myGallery.setVerticalScrollBarEnabled(false);
Nemat
  • 29
  • 5

0 Answers0