Mhm das habe ich eigentlich so implentiert. Aber es zeigt mir nun nur immer das Layout an welches im onCreateView ist an. Egal ob ich Daten habe oder nicht.
Das weekFragement ist das normale Layout:
1<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
2 android:layout_width="match_parent"
3 android:layout_height="match_parent"
4 android:orientation="vertical" >
5
6 <TableLayout
7 android:layout_width="fill_parent"
8 android:layout_height="fill_parent"
9 android:stretchColumns="*" >
10
11 <TableRow
12 android:id="@+id/columnName"
13 android:layout_width="wrap_content"
14 android:layout_height="wrap_content" >
15
16 <TextView
17 android:id="@+id/Datum"
18 android:layout_width="wrap_content"
19 android:layout_height="wrap_content"
20 android:text="@string/dateName"
21 android:textSize="20dip" />
22
23 <TextView
24 android:id="@+id/subjectName"
25 android:layout_width="wrap_content"
26 android:layout_height="wrap_content"
27 android:text="@string/subjectName"
28 android:textSize="20dip" />
29
30 <TextView
31 android:id="@+id/roomNumberName"
32 android:layout_width="wrap_content"
33 android:layout_height="wrap_content"
34 android:gravity="right"
35 android:text="@string/roomNumberName"
36 android:textSize="20dip" />
37 </TableRow>
38 </TableLayout>
39
40 <ListView android:id="@id/android:list"
41 android:layout_width="match_parent"
42 android:layout_height="match_parent"
43 android:background="#00FF00"
44 android:layout_weight="1"
45 android:drawSelectorOnTop="false"/>
46
47 <TextView android:id="@id/android:empty"
48 android:layout_width="match_parent"
49 android:layout_height="match_parent"
50 android:background="#FF0000"
51 android:text="No data"/>
52
53</LinearLayout>
Und hier ist die Listfragment mit den 2 Aufrufen. Stimmen die denn?
1@Override
2 public View onCreateView(LayoutInflater inflater, ViewGroup container,
3 Bundle savedInstanceState) {
4 // TODO Auto-generated method stub
5 LinearLayout rl = (LinearLayout) inflater.inflate(R.layout.week_fragment, container, false);
6 return rl;
7
8
9
10
11 }
12
13
14
15 @Override
16 public void onActivityCreated(Bundle savedInstanceState) {
17 super.onActivityCreated(savedInstanceState);
18
19
20
21 Cursor cursor = getWeekDates();
22
23 String[] columns = new String[] { "start", "zimmerNr", "kuerzel" };
24
25 int[] to = new int[] { R.id.date, R.id.schoolSubjectShort, R.id.roomNumberName };
26
27 DatabaseCursorAdapter dbCursorAdapter = new DatabaseCursorAdapter(getActivity().getApplicationContext(), R.layout.database_items, cursor, columns, to, 1);
28
29 setListAdapter(dbCursorAdapter);
30 }
Empfohlener redaktioneller Inhalt
Mit Deiner Zustimmung wird hier ein externer Inhalt geladen.
Mit Klick auf den oben stehenden Button erklärst Du Dich damit einverstanden, dass Dir externe Inhalte angezeigt werden dürfen. Dabei können personenbezogene Daten an Drittanbieter übermittelt werden. Mehr Infos dazu findest Du in unserer Datenschutzerklärung.