fügen Sie anzeigen dynamisch in einem fragment

Brauche ich, um zu zeigen, einige Informationen im agenda-Stil, so dass ich mit fragment zeigen die Informationen in die verschiedenen Tage. Jeden Tag haben einige Spalte zeigt den Raum.

Erstelle ich die Struktur, aber ich habe ein problem wenn ich versuche von innen die Informationen

agenda_child_tv - textview, wo ich die Ruhe von Informationen

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

agenda_child_ll - die colum

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

agenda_day

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

Agenda

Den code unten ist nicht sehr dynamisch, aber ich schrieb eine vereinfachte Version, Ihnen zu zeigen, mein problem

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);
}

Dies ist das Ergebnis. Die textview Kind war nicht zum layout Hinzugefügt.
Kann mir jemand helfen? 🙂

Bild von dem Ergebnis

  • Ich fühle mich ein bisschen wie Sie sein sollte versuchen, zu verwenden gridview mit einem adapter anstelle von dem, was du tust. Adapter sollen sehr effizient arbeiten mit dynamischen Daten
  • Danke. Aber ich denke, dass mit der gridwith Sie Blättern können nur vertikale oder horizontale, nicht beide... ich habe das problem gelöst, änderte ich layout_height in agenda_aula_title.
InformationsquelleAutor user2110763 | 2013-03-06
Schreibe einen Kommentar