How to have some texviews in a row in a ListView? android

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?

Answers


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.


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


you are setting the orientation as vertical:

android:orientation="vertical"

remove it, and you should get the textview horizzontal


Need Your Help

Performance: condition testing vs assignment

php performance conditional variable-assignment

I've created a loop where a variable is used to test if the current run-through of the loop is the first one. Its fairly simple:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.