0

アプリに簡単なフォーラムを作成しました。ユーザーが 2 行以上の質問を投稿した場合、カスタム リストビューに表示できるようにしたいと考えています。android:maxLines="7" を設定しようとしても、2 行以上の表示を拒否しますか? これを修正するにはどうすればよいですか? この問題に対する答えを見つけることができませんでした....これは私のxmlコードです:

編集: 問題は、ユーザーのコメントが listView に表示される TextView (android:id="@+id/feedback_list_item_comment") で発生します...

<?xml version="1.0" encoding="utf-8"?>


<TableLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/linearLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:stretchColumns="1"
    android:weightSum="1.0"
    android:background="@drawable/rowselector"

    >

    <TableRow
        >

    <TextView
        android:id="@+id/feedback_list_item_name"
        android:layout_width="0dip"
        android:layout_height="fill_parent"
        android:layout_weight="0.46"
        android:singleLine="true"
        android:gravity="left"
        android:shadowColor="#bdbebd"
        android:shadowDx="1.0"
        android:shadowDy="1.0"
        android:shadowRadius="0.5"
        android:text="Unknown"
        android:textColor="#000000"
        android:textSize="14dp"
        android:textStyle="bold" 
        android:layout_marginLeft="3dp"/>

    <TextView
        android:id="@+id/feedback_list_item_time"
        android:layout_width="0dip"
        android:layout_height="fill_parent"
        android:layout_weight="0.46"
        android:singleLine="true"
        android:gravity="left"
        android:shadowColor="#bdbebd"
        android:shadowDx="1.0"
        android:shadowDy="1.0"
        android:shadowRadius="1.0"
        android:text="dd.mm.yy"
        android:textColor="#3c6dae"
        android:textSize="14dp"
         />

    <TextView
        android:id="@+id/feedback_list_item_replies"
        android:layout_width="0dip"
        android:layout_height="fill_parent"
        android:maxLines="1"
        android:gravity="center"
        android:shadowColor="#bdbebd"
        android:shadowDx="1.0"
        android:shadowDy="1.0"
        android:shadowRadius="1.0"
        android:layout_weight="0.08"
        android:textColor="#000000"
        android:textSize="14dp"
        android:layout_marginRight="3dp"

        > 
        </TextView>

これは、行数を 7 に設定したい以下のコメント TextView です....:

<TableRow>

 <TextView
        android:id="@+id/feedback_list_item_comment"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:maxLines="7"
        android:layout_marginLeft="3dp"
        android:layout_marginBottom="4dp"
        android:gravity="left"
        android:shadowColor="#bdbebd"
        android:shadowDx="1.0"
        android:shadowDy="1.0"
        android:shadowRadius="1.0"
        android:text="No comment"
        android:textColor="#666666"
        android:textSize="12dp"
       >            
        </TextView>    

</TableRow>
 </TableLayout>
4

1 に答える 1

0

十分なコードを投稿していませんが、Android ライブラリの標準的な 2 行のリスト ビューを使用していると思います。リスト ビュー アイテムの外観を完全に制御したい場合は、カスタム ビューを作成ArrayAdapter<...>し、それらをロードするカスタム アダプターで拡張する必要があります。

初めてやったときはこれに怯えましたが、実際にはそれほど多くの作業はなく、ListView を制御することは時間の価値があることがわかります。

開始するためのリンクは次のとおりです: http://www.ezzylearning.com/tutorial.aspx?tid=1763429

于 2012-07-19T14:04:34.190 に答える