2012-11-24 3 views
2

아주 간단한 질문이지만 어떻게해야하는지 모르겠다. 각 행을 표시하는 listview 어댑터와 xml 행이 있습니다. 하나의 행에 3 개의 텍스트 뷰를 표시하려고합니다. 나는 텍스트는 다음과 같이 표시 할여러 줄의 텍스트 뷰

<?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> 

: 이것은 내 XML 코드

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

미리 감사드립니다.

답변

5

방향을 LinearLayout의 android:orientation="horizontal"으로 변경하십시오.

편집

어떻게 내가 좋아 표시하려는 경우 : 두 번째 줄에 한 줄의 txt1 및 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> 
+0

Ok 바보 같아요. D 감사합니다. – Davis

+0

어떻게 표시하고 싶습니다 : txt1 한 줄에 txt2 txt3 두 번째 줄에 표시하고 싶습니다. – Davis

+0

한 줄에 txt1, 두 번째 줄에 txt2 txt3에 대한 답변을 업데이트했습니다. –

1

은 수직에서 수평으로 방향을 변경하는 것입니다.