我需要以议程样式显示一些信息,因此我使用片段来显示不同日期的信息。每天都有一些专栏来展示房间。
我创建了结构,但是当我尝试放入信息时遇到了一些问题
议程_儿童电视 - 我放置信息和平的文本视图
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text_child"
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:clickable="true"
android:background="@drawable/back"
android:padding="3sp"/>
议程_儿童_ll - 列
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="@dimen/agenda_aula_width"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/agenda_aula_title"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<LinearLayout
android:id="@+id/agenda_aula_esp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
议程日
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ScrollView
android:layout_width="wrap_content"
android:layout_height="match_parent" >
<LinearLayout
android:id="@+id/horizontal_fragment"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="@dimen/agenda_tv_width"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#BDBDBD" >
<TextView
android:layout_width="@dimen/agenda_tv_width"
android:layout_height="@dimen/agenda_tv_height"
android:text="9.00"
android:padding="@dimen/agenda_tv_padding"
android:textColor="@color/agenda_orario_color"
android:textSize="@dimen/agenda_tv_textsize" />
<!-- A lot of textview for the hours -->
</LinearLayout>
<!-- Here i put, dinamically, the colum for the room in each day -->
</LinearLayout>
</ScrollView>
</HorizontalScrollView>
议程
下面的代码不是很动态,但我写了一个简化的版本来告诉你我的问题
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.agenda_day, container, false);
LinearLayout dayLL = (LinearLayout) rootView.findViewById(R.id.horizontal_fragment);
//Retriving LL agenda_child_ll
LinearLayout aula = (LinearLayout) inflater.inflate(R.layout.agenda_child_ll, container, false);
//Setting the classroom name
TextView aulaName = (TextView) aula.findViewById(R.id.agenda_aula_title);
aulaName.setText("room A");
//Retriving LL agenda_aula_esp
LinearLayout roomLL = (LinearLayout) aula.findViewById(R.id.agenda_aula_esp);
//Retriving TV child
TextView child = (TextView) inflater.inflate(R.layout.agenda_child_tv, container, false);
child.setText("test");
//Adding child to the room
roomLL.addView(child);
//adding room to the day
dayLL.addView(aula);
//Creating the column for the classroom "room B"
LinearLayout aula2 = (LinearLayout) inflater.inflate(R.layout.agenda_child_ll, container, false);
TextView aulaName2 = (TextView) aula2.findViewById(R.id.agenda_aula_title);
aulaName2.setText("room B");
dayLL.addView(aula2);
}
这就是结果。textview 子项未添加到布局中。有人能帮我吗?:)