1

In this application i tag the data using json parsing and binding the data using list adapter and i was add the heading for data in static using table layout, when i scroll horizontally the data scroll with heading but horizontal scroll view only allowed to only one child, i need two layout in single horizontal scroll view. please help

my xml is

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     android:background="#ffffff"
     android:orientation="vertical">
<!-- Main ListView Always give id value as list(@android:id/list) -->
   <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:background="#ffffff"
         android:orientation="horizontal">

     <TableRow
         android:id="@+id/tableRow1"
         android:scrollbarAlwaysDrawHorizontalTrack="true"
         android:layout_height="wrap_content"
         android:layout_width="match_parent">

         <TextView
            android:id="@+id/TextView2"
            android:text="GRPName"
            android:background="#A513FF"

            android:textColor="#000000"
            android:layout_width="150dp"
            android:padding="3dip"
            android:gravity="left"/>

         <TextView
            android:id="@+id/TextView3" android:text="NAME"
            android:background="#A513FF"
            android:textColor="#000000"
            android:layout_width="100dp"
            android:padding="3dip" android:gravity="left"/>

         <TextView
            android:id="@+id/TextView4" android:text="MRP"
            android:background="#A513FF"
            android:textColor="#000000"
            android:layout_width="100dp"
            android:padding="3dip" android:gravity="left"/>

         <TextView
            android:id="@+id/TextView5" android:text="QNT"
            android:background="#A513FF"
            android:textColor="#000000"
            android:layout_width="100dp"
            android:padding="3dip" android:gravity="left"/>

         <TextView
            android:id="@+id/TextView2" android:text="ID"
            android:background="#A513FF"
            android:textColor="#000000"
            android:layout_width="100dp"
            android:padding="3dip"
            android:gravity="left"/>

        <TextView
            android:id="@+id/TextView3" android:text="NAME"
            android:background="#A513FF"
            android:textColor="#000000"
            android:layout_width="100dp"
            android:padding="3dip" android:gravity="left"/>

    </TableRow>
  </LinearLayout>

  <HorizontalScrollView
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:id="@+id/horizontalScrollView">
    <ListView
            android:id="@android:id/list"
            android:smoothScrollbar="true"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/>
  </HorizontalScrollView>
</LinearLayout>

I need to table layout in the horizontal scroll view

Royston Pinto
  • 6,681
  • 2
  • 28
  • 46
ibu
  • 577
  • 4
  • 9
  • 24
  • here is a link for a horizontal-list-view lib: http://www.dev-smart.com/archives/34 (perhaps this will hepl you)... – owe Jul 05 '13 at 14:20

1 Answers1

4

You have to put one layout as a scrollviews child, then put every other views in that child and it should work fine.

Like this way:

<HorizontalScrollView
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:id="@+id/horizontalScrollView">

    <LinearLayout ... >
    ... insert your views in here
    </LinearLayout>
</HorizontalScrollView>
vilpe89
  • 4,656
  • 1
  • 29
  • 36
  • hi, here how to add views programatically to LinearLayout. Please help me – Gangadhar Nimballi Oct 09 '13 at 14:02
  • Lets assume that you have `LinearLayout` in your xml and it's id is for example `myLayout`. Now in onCreate after calling `setContentView(R.layout.yourMainLayout);` one way to add view is to do this `((LinearLayout) findViewById(R.id.myLayout)).addView(yourView);`. – vilpe89 Oct 10 '13 at 12:22