Android 如何在listView中设置多于2行?

Android 如何在listView中设置多于2行?,android,listview,Android,Listview,我在我的应用程序中创建了一个简单的论坛。如果用户发布的问题超过两行,我希望能够在自定义listview中显示它。即使我尝试设置android:maxLines=“7”,它也会拒绝显示超过2行的内容?我该如何解决这个问题?我一直找不到这个问题的答案。。。。这是我的xml代码: 编辑:问题出现在文本视图(android:id=“@+id/feedback\u list\u item\u comment”)中,用户的评论显示在列表视图中 <?xml version="1.0" encoding=

我在我的应用程序中创建了一个简单的论坛。如果用户发布的问题超过两行,我希望能够在自定义listview中显示它。即使我尝试设置android:maxLines=“7”,它也会拒绝显示超过2行的内容?我该如何解决这个问题?我一直找不到这个问题的答案。。。。这是我的xml代码:

编辑:问题出现在文本视图(android:id=“@+id/feedback\u list\u item\u 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….:

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

您没有发布足够的代码,但我敢打赌您使用的是Android库中的标准两行列表视图。如果希望完全控制列表视图项的外观,则需要创建自定义视图,并使用自定义适配器扩展
ArrayAdapter
,以加载它们

我第一次这么做的时候就被它吓倒了,但实际上这并没有那么多工作,你会发现控制你的ListView是非常值得的


这里有一个链接可以帮助您入门:

使用ListView的自定义适配器。