Stefan S.
- Forum-Beiträge: 560
22.06.2011, 07:29:02 via Website
22.06.2011 07:29:02 via Website
Ich habe folgendes Problem:
Mein UI sieht folgendermassen aus
Um die ListView abzufüllen habe ich ein Custom Adapter gebaut. Klickt man auf die ImageButtons, wird die Menge incrementiert oder gelöscht. Dies funktioniert auch perfekt mit Cursor.requery() nach der Modifikation.
Mein Problem ist die TextView, welche das Total berechnet. Beim Starten der Activity steht auch das richtige Total drin. Wenn ich eben nun die ImageButtons drücke und im CustomAdapter die neuen Werte reinschreibe wird das Total nicht neu berechnet, da ich keinen Zugriff auf die TextView habe.
Gibt es eine Möglichkeit der Actitiy zu sagen, dass sie sich neu aufbauen soll?
Mein UI sieht folgendermassen aus
1<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
2 android:orientation="vertical"
3 android:layout_width="fill_parent"
4 android:layout_height="fill_parent"
5 >
6 <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/lvOrderLinear">
7 <TextView android:layout_width="wrap_content" android:text="Bestellungsübersicht" android:id="@+id/txtOrderTitle" android:layout_height="wrap_content" android:textStyle="bold"></TextView>
8 <View android:layout_width="fill_parent" android:id="@+id/separatorOrder" android:layout_height="10dip"></View>
9 </LinearLayout>
10 <ListView android:layout_height="wrap_content" android:layout_below="@+id/lvOrderLinear" android:layout_width="fill_parent" android:id="@+id/lvOrder" android:layout_marginTop="20dp" android:layout_marginBottom="60dp"></ListView>
11 <LinearLayout android:layout_width="fill_parent" android:layout_above="@+id/btnOrder" android:layout_height="wrap_content" android:id="@+id/lvOrderLinearTotal" android:orientation="horizontal" android:layout_alignParentBottom="true">
12 <TextView android:layout_width="fill_parent" android:layout_weight="1" android:text="Total" android:id="@+id/txtOrderTitleTotal" android:layout_height="wrap_content" android:textStyle="bold"></TextView>
13 <TextView android:layout_width="fill_parent" android:layout_weight="1" android:text="abc" android:id="@+id/txtOrderTitleTotalPreis" android:layout_height="wrap_content" android:textStyle="bold"></TextView>
14 <ImageButton android:layout_width="wrap_content" android:src="@drawable/basket_go" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:id="@+id/btnOrder" android:text="Bestellen"></ImageButton>
15 </LinearLayout>
16
17</RelativeLayout>
2 android:orientation="vertical"
3 android:layout_width="fill_parent"
4 android:layout_height="fill_parent"
5 >
6 <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/lvOrderLinear">
7 <TextView android:layout_width="wrap_content" android:text="Bestellungsübersicht" android:id="@+id/txtOrderTitle" android:layout_height="wrap_content" android:textStyle="bold"></TextView>
8 <View android:layout_width="fill_parent" android:id="@+id/separatorOrder" android:layout_height="10dip"></View>
9 </LinearLayout>
10 <ListView android:layout_height="wrap_content" android:layout_below="@+id/lvOrderLinear" android:layout_width="fill_parent" android:id="@+id/lvOrder" android:layout_marginTop="20dp" android:layout_marginBottom="60dp"></ListView>
11 <LinearLayout android:layout_width="fill_parent" android:layout_above="@+id/btnOrder" android:layout_height="wrap_content" android:id="@+id/lvOrderLinearTotal" android:orientation="horizontal" android:layout_alignParentBottom="true">
12 <TextView android:layout_width="fill_parent" android:layout_weight="1" android:text="Total" android:id="@+id/txtOrderTitleTotal" android:layout_height="wrap_content" android:textStyle="bold"></TextView>
13 <TextView android:layout_width="fill_parent" android:layout_weight="1" android:text="abc" android:id="@+id/txtOrderTitleTotalPreis" android:layout_height="wrap_content" android:textStyle="bold"></TextView>
14 <ImageButton android:layout_width="wrap_content" android:src="@drawable/basket_go" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:id="@+id/btnOrder" android:text="Bestellen"></ImageButton>
15 </LinearLayout>
16
17</RelativeLayout>
Um die ListView abzufüllen habe ich ein Custom Adapter gebaut. Klickt man auf die ImageButtons, wird die Menge incrementiert oder gelöscht. Dies funktioniert auch perfekt mit Cursor.requery() nach der Modifikation.
Mein Problem ist die TextView, welche das Total berechnet. Beim Starten der Activity steht auch das richtige Total drin. Wenn ich eben nun die ImageButtons drücke und im CustomAdapter die neuen Werte reinschreibe wird das Total nicht neu berechnet, da ich keinen Zugriff auf die TextView habe.
Gibt es eine Möglichkeit der Actitiy zu sagen, dass sie sich neu aufbauen soll?
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.