ein statisches Layout mit einer ListView mischen

  • Antworten:2
ECR
  • Forum-Beiträge: 72

03.10.2012, 20:54:26 via Website

Ich habe folgende Situation, ich bin soweit das ein Resultat aus der DB kommt und diese dann, jenachdem wieviele es sind, in einem Listfragment dargestellt werden. Wie sie dargestellt werden habe ich in einem Layout definiert. Ich habe auch einen eigenen Adapter gemacht. Ich hätte das gerne oben immer steht:
Was muss ich dazu tun?




DatumFachSchulzimmernummer







1.2.2012Physik312
2.2.2012Mathe222
3.2.2012Deutsch234

Antworten
ECR
  • Forum-Beiträge: 72

04.10.2012, 00:11:40 via Website

Ok ich habe hier mal meinen Code:

Das ist ein Ausschnitt aus dem Fragment. Die "onCreateView "wird zwar aufgerufen, aber dann sieht man nur das weekfragment. Die andere Methode wird zwar auch aufgerufen "onActivityCreated" aber die hat keine Wirkung. Erst wenn ich "onCreateView" entferne funktioniert diese Methode wieder.
Ich hoffe jemand kann mir einen Ansatz geben
1@Override
2 public View onCreateView(LayoutInflater inflater, ViewGroup container,
3 Bundle savedInstanceState) {
4 View view = inflater.inflate(R.layout.week_fragment, container, false);
5
6 return view;
7 }
8
9 @Override
10 public void onActivityCreated(Bundle savedInstanceState) {
11 super.onActivityCreated(savedInstanceState);
12
13 Cursor cursor = getWeekDates();
14
15 String[] columns = new String[] { "start", "zimmerNr", "kuerzel" };
16
17 int[] to = new int[] { R.id.date, R.id.schoolSubjectShort,
18 R.id.roomNumberName };
19
20 DatabaseCursorAdapter dbCursorAdapter = new DatabaseCursorAdapter(
21 getActivity().getApplicationContext(), R.layout.database_items,
22 cursor, columns, to, 1);
23
24 setListAdapter(dbCursorAdapter);
25 }

Das ist die XML welchen die Rows erzeugt sie heisst database_items:
1<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
2 android:layout_width="fill_parent"
3 android:layout_height="fill_parent"
4 android:stretchColumns="1" >
5
6 <TableRow
7 android:id="@+id/tableRow1"
8 android:layout_width="wrap_content"
9 android:layout_height="wrap_content" >
10 </TableRow>
11
12 <TableRow android:layout_marginTop="10dip" >
13
14 <TextView
15 android:id="@+id/date"
16 android:layout_width="wrap_content"
17 android:layout_height="wrap_content"
18 android:layout_marginLeft="10dip"
19 android:gravity="left"
20 android:padding="3dip"
21 android:textColor="#000000"
22 android:textSize="18dip" >
23 </TextView>
24
25 <TextView
26 android:id="@+id/roomNumberName"
27 android:layout_width="wrap_content"
28 android:layout_height="wrap_content"
29 android:gravity="center"
30 android:padding="3dip"
31 android:textColor="#000000"
32 android:textSize="18dip" >
33 </TextView>
34
35 <TextView
36 android:id="@+id/schoolSubjectShort"
37 android:layout_width="wrap_content"
38 android:layout_height="wrap_content"
39 android:layout_marginRight="10dip"
40 android:gravity="right"
41 android:padding="3dip"
42 android:textColor="#000000"
43 android:textSize="18dip" >
44 </TextView>
45 </TableRow>
46
47</TableLayout>

Und das wäre die XML welche gerne nur einmal zuoberst hätte, sie heisst weekFragment:
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
41 android:id="@android:id/list"
42 android:layout_width="fill_parent"
43 android:layout_height="fill_parent"
44 >
45 </ListView>
46
47</LinearLayout>

Antworten
ECR
  • Forum-Beiträge: 72

04.10.2012, 09:27:06 via Website

Hat niemand einen Ansatz oder Idee? Ich habe das Gefühl das ich nicht weit von der Lösung entfernt bin... :-)

Antworten