I have a ListView
in which I show some details including prices.
I need to show the total sum at the bottom of the ListView
.
So far I've tried with a ListView
to show the details and a table layout with a single row to show the total, the problem is that I can't get them to be aligned.
Do you know I can get a result like this one:
I know that the amount for "Cache" isn't the Total, but the idea is the same. All these rows show their amounts properly aligned and the space between the labels and the amount are filled with dots and this is the result I'd like to achieve, so I would be very grateful if you could help.
This is the layout I'm currently using for my activity
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical" >
<ListView
android:id="@+id/detailsListView"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:dividerHeight="1dp" >
</ListView>
</LinearLayout>
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:stretchColumns="0,1" >
<TableRow android:padding="1dp" >
<TextView
style="@style/Control.Label.Large.Stretched"
android:layout_weight="1"
android:text="@string/total" />
<TextView
android:id="@+id/totalSumTextView"
style="@style/Control.TextView.Large.Stretched"
android:layout_weight="1"/>
</TableRow>
<TableRow android:id="@+id/tableRow3" />
</TableLayout>
</LinearLayout>
An this is the layout for each item in the ListView :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:stretchColumns="0,1" >
<TableRow android:padding="1dp" >
<TextView
style="@style/Control.Label.Small.Stretched"
android:layout_weight="1"
android:text="@string/item_quantity" />
<TextView
android:id="@+id/itemQuantityTextView"
style="@style/Control.TextView.Small.Stretched"
android:layout_weight="1" />
</TableRow>
<TableRow android:padding="1dp" >
<TextView
style="@style/Control.Label.Small.Stretched"
android:layout_weight="1"
android:text="@string/item_unit_price" />
<TextView
android:id="@+id/itemUnitPriceTextView"
style="@style/Control.TextView.Small.Stretched"
android:layout_weight="1" />
</TableRow>
<TableRow android:padding="1dp" >
<TextView
style="@style/Control.Label.Small.Stretched"
android:layout_weight="1"
android:text="@string/item_total" />
<TextView
android:id="@+id/itemTotalTextView"
style="@style/Control.TextView.Small.Stretched"
android:layout_weight="1" />
</TableRow>
</TableLayout>
</LinearLayout>
Each Item should look something like this :
And it's the sum of those totals that should be displayed below the ListView
This image is from what I'm trying to do. It's in Spanish, but it should give you a better picture of what I'm saying. As you can see the row below the ListView is not aligned with the values in the above it.