1

이 응용 프로그램에서 json 파싱을 사용하여 데이터에 태그를 지정하고 목록 어댑터를 사용하여 데이터를 바인딩하고 가로로 스크롤 할 때 테이블 레이아웃을 사용하여 정적으로 데이터 제목을 추가했습니다. 데이터 스크롤을 제목과 함께하지만 가로 스크롤보기는 하나의 자식에게만 허용되므로 하나의 가로 스크롤보기에서 두 개의 레이아웃이 필요합니다. 도와주세요안드로이드에서 가로 스크롤보기에서 여러 자식을 추가하는 방법

내 XML은

<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> 

내가 가로 스크롤 뷰에서 테이블 레이아웃에 필요하다

+0

는 수평 목록보기 lib 디렉토리에 대한 링크입니다. .. – owe

답변

3

당신은 다음, scrollviews의 자식으로 하나의 레이아웃을 넣어 그 아이의 모든 다른 견해를 넣어 가지고 그것은 잘 작동합니다. 이 방법처럼

: http://www.dev-smart.com/archives/34 (아마도이 ​​당신을 hepl 것) : 여기

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

    <LinearLayout ... > 
    ... insert your views in here 
    </LinearLayout> 
</HorizontalScrollView> 
+0

안녕하세요, 선형 방식으로 뷰를 LinearLayout에 추가하는 방법은 다음과 같습니다. 제발 도와주세요 –

+0

XML에'LinearLayout'이 있다고 가정하고 ID는'myLayout'입니다. 이제 setContentView (R.layout.yourMainLayout);를 호출 한 후 onCreate에서보기를 추가하는 한 가지 방법은'((LinearLayout) findViewById (R.id.myLayout)). addView (yourView);'를 사용하는 것입니다. – vilpe89

관련 문제