Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/198.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android ListView带有多行文本视图空间行_Android_Xml_Android Layout_Listview_Textview - Fatal编程技术网

Android ListView带有多行文本视图空间行

Android ListView带有多行文本视图空间行,android,xml,android-layout,listview,textview,Android,Xml,Android Layout,Listview,Textview,list_layout.xml: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_marginLeft="6dp" android:layout_marginRight="6dp"

list_layout.xml:

<LinearLayout  xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_marginLeft="6dp"
    android:layout_marginRight="6dp"
    >
<TextView
        android:id="@+id/txtAdi"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:textColor="@color/DarkGreen"
         />

我在textview中添加了android:maxLines=“2”和android:ellipsize=“end”,然后如下所示:

<ListView
    android:id="@+id/listView1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center_horizontal"
    android:listSelector="@drawable/listselector" >
</ListView>
sample text 1 ------------------- sample multiline text 2 -------------------- sample text 3 --------------------

sample text 1 ------------------- sample multiline text 2... -------------------- sample text 3 -------------------- 示例文本1 ------------------- 样本多行 文本2。。。 -------------------- 示例文本3 -------------------- 所以我想显示最多两行,如果超过两行的文本附加了三个点。
这是可能的解决方案。

您能粘贴列表适配器代码吗?我添加了列表适配器代码确保您的文本数据结尾不包含新行('\n')符号。没有新行符号我复制了您的代码,这给了我一个很好的结果。我想你应该考虑一下你的光标,它可能会在结尾或其他地方设置一条新的线,试着打印出这些多行项目,看看它的末尾是否有什么东西。


    SimpleCursorAdapter adapter = new SimpleCursorAdapter(
                    getApplicationContext(), R.layout.list_layout, c, from, to, 10);

            ListView list = (ListView) findViewById(R.id.listView1);

            list.setAdapter(adapter);
  <TextView
        android:id="@+id/txtAdi"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:textColor="@color/DarkGreen"
        android:maxLines="2"
        android:ellipsize="end"
         />
sample text 1 ------------------- sample multiline text 2... -------------------- sample text 3 --------------------