2013-03-04 3 views
0

저는 Android 개발자의 초보자입니다. 다음과 고민하고 있습니다. 프로그래밍 방식으로 생성 된 tablelayout을 사용하여 Fragment를 만들고 싶습니다. 내가 먼저 활동이 아닌 것을 내가 한 조각에서 시작 :Scrollview 및 tablelayout을 사용한 단편 레이아웃 제한

protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    View view = getLayoutInflater().inflate(R.layout.activity_testtable, null,false); 
    fillLayout(view);  
    setContentView(view); 
} 

protected void fillLayout(View rootView) { 

    TableLayout tl; 
    TableRow tr; 
    TextView tv; 
    int i = 0; 

    tl = (TableLayout) rootView.findViewById(R.id.time_range); 

    for (i = 0 ; i < 10 ; i++) { 
     tv = new CellWorkshopTable(this); 
     tv.setText("11h00 - 14h40"); 
     tr = new TableRow (this); 
     tr.addView(tv);  
     tl.addView(tr); 
    } 

    [...] 

} 

그것은 잘 작동 내가 그럼 난 조각이 점을 설정하고 싶었 등 등 축 2 스크롤로 원하는대로, 테이블이 만들어졌습니다,

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 

    View aView = inflater.inflate(R.layout.activity_testtable, container, false); 
    fillLayout(aView); 
    return aView; 
} 

내가 조각, 로그 캣에 오류를 저지 그래서 아무것도 표시되지 않습니다, 더 충돌, 모두가 아무것도 표시되지 않는 것으로 보인다 : 그래서 나는 내 조각에 다음했다. 이 질문에 을 쓸 때 내가 레이아웃을 단순화하기 위해 노력 그래서

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/time_table" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:scrollbars="vertical" 
android:padding="0dp" 
android:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" > 

<LinearLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" 
    android:padding="0dp" > 

    <TableLayout 
     android:id="@+id/time_range" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" > 
    </TableLayout> 

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

     <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:orientation="vertical" 
      android:padding="0dp" > 

      <TableLayout 
       android:id="@+id/header_rooms" 
       android:layout_width="wrap_content" 
       android:layout_height="match_parent" > 
      </TableLayout> 

      <TableLayout 
       android:id="@+id/time_table_content" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" > 
      </TableLayout> 
     </LinearLayout> 
    </HorizontalScrollView> 
</LinearLayout> 
</ScrollView> 

: 여기

레이아웃이며, 목적은 전체 구조를 가지고 있고, 단지 (textviews 있습니다)을 tableRow 셀을 추가하는 것입니다 다음 HorizontalScrollView와 그의 차일 등을 제거하여 TableRows는 header_rooms가 작동하고 time_table_content KO, 다음 첫 번째 TableLayout을에 추가

HorizontalScrollView를 제거하지만, TableLayout을 + 아이디/header_rooms 및 TableLayout을 + 아이디/time_table_content을 유지을 표시.

조각에는 레이아웃 번호 제한이 있습니다. 어떻게 이것을 복제 할 수 있습니까?

답변

0

사실 내 레이아웃에서 불필요한 요소를 모두 정리하면 intented로 작동합니다.

그래서 조각은 레이아웃 요소 조합에 대해 "엄격한"것처럼 보입니다.

관련 문제