使列表视图仅显示每个项目的第一行

make listview show only the first line of each item

我想让一个列表视图项目只显示一行...最后当项目的字符串多于一行时 就像这样

项目 1 非常好。

我想让它看起来像这样

项目 1 ....

因为列表视图边界将位于 "is" 所以,我不想只有一行 我有一个带有列表视图布局的基本操作栏 activity,XML 代码是

<?xml version="1.0" encoding="utf-8"?>`
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

请注意,项目将动态添加。

谢谢

请将这两行添加到列表视图适配器项目的文本视图中。

android:singleLine="true"
android:ellipsize="end"

singleLine 已删除,请使用 maxLines 喜欢

android:maxLines="1"
android:ellipsize="end"