4

とても簡単な質問ですが、どうすればいいのかわかりません。各行を表示するリストビュー アダプターと xml 行があります。3 つのテキストビューを 1 行に表示したい。これは私のXMLコードです:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">
  <TextView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/txtElement"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="24px"
        android:textColor="#000000">
    </TextView>
      <TextView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/txtElement2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="24px"
        android:textColor="#000000">
    </TextView>
      <TextView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/txtElement3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="24px"
        android:textColor="#000000">
    </TextView>

</LinearLayout>

テキストを次のように表示したい:

txt1 txt2 txt3

そして、これは私のアダプターコードです(しかし、問題はXMLにあると思います):

    TextView tv = (TextView) row.findViewById(R.id.txtElement);
    tv.setText(currentElement.getTitle());          

    TextView tv2 = (TextView) row.findViewById(R.id.txtElement2);
    tv2.setText(currentElement.getAuthor());            

    TextView tv3 = (TextView) row.findViewById(R.id.txtElement3);
    tv3.setText(""+currentElement.getNumPost());

前もって感謝します。

4

2 に答える 2

7

android:orientation="horizontal"LinearLayout の向きを変更します。

編集

1行目にtxt1、2行目にtxt2 txt3のように表示したい場合はどうすればよいですか?

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="5dp"
        android:layout_marginTop="5dp"
        android:text="1" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/textView1"
        android:layout_below="@+id/textView1"
        android:text="2" />

    <TextView
        android:id="@+id/textView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textView1"
        android:layout_marginLeft="5dp"
        android:layout_toRightOf="@+id/textView2"
        android:text="3" />

</RelativeLayout>
于 2012-11-24T18:46:40.553 に答える
1

あなたがする必要があるのは、向きを垂直から水平に変更することだけです。

于 2012-11-24T18:47:01.433 に答える