Reputation: 4065
I have a ListActivity where I have some items sorted by datetime. I have 3 textviews. Here what I've done:
Here is the code for the layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/bpSysHolder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" >
</TextView>
<TextView
android:id="@+id/bpDiaHolder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" >
</TextView>
<TextView
android:id="@+id/bpDtHolder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" >
</TextView>
</LinearLayout>
For calling them from my list activity i use:
String[] from = new String[] { BpDAO.bp_SYS, BpDAO.bp_DIA, BpDAO.bp_DT };
int[] target = new int[] { R.id.bpSysHolder, R.id.bpDiaHolder,
R.id.bpDtHolder };
dbAdapter = new SimpleCursorAdapter(this, R.layout.history_bp, bpList,
from, target);
setListAdapter(dbAdapter);
Now it is like this:
---120952012-09-20 15:05 ---
---145902012-09-20 10:44 ---
---145952012-09-20 10:42 ---
...
---14595 2012-09-20 10:42 ---
---------------------------------
How to have space between them and some little space up and down of the row so to be easier to touch?
Upvotes: 0
Views: 97
Reputation: 157447
you are setting the orientation as vertical:
android:orientation="vertical"
remove it, and you should get the textview horizzontal
Upvotes: 1
Reputation: 4556
Use this on the linear layout to have all in one line
android:orientation="horizontal"
On the picture you already have a title on the action bar, if you want on the list you can add a header to the list
Upvotes: 1
Reputation: 1698
you can do this also in same layout.
Change android:orientation="vertical" > to android:orientation="horizontal"
and define use the property "Android:layout_weight" for text-view to aline according to your reqirement.
Upvotes: 1