0

我有一個ListActivity,我有一些按日期時間排序的項目。 我有3個textviews.Here我做了什麼:如何在一個ListView中有一些texview? android

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> 

對於從我的名單活動美其名曰我使用:

 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); 

現在是這樣的:

---120952012-09-20 15:05  --- 
---145902012-09-20 10:44  --- 
---145952012-09-20 10:42  --- 
      ... 
---14595 2012-09-20 10:42  --- 
--------------------------------- 

如何在它們之間留出空間,並在行的上下方向上留出一些空間,以便更容易觸摸?

回答

1

你可以在同樣的佈局中做到這一點。

Change android:orientation="vertical" > to android:orientation="horizontal" 

並根據您的要求定義使用屬性「Android:layout_weight」作爲文本視圖。

1

使用此的線性佈局都在一行

android:orientation="horizontal" 

圖片上你已經有操作欄上的標題,如果你想在名單上,你可以在頭添加到列表

1

要設置方向爲垂直:

android:orientation="vertical" 

刪除它,你應該得到的TextView horizzontal

相關問題