【发布时间】:2014-06-10 02:55:28
【问题描述】:
我有以下问题: 我创建了一个 row.xml 文件以在我的 CustomAdapter 中使用。此行将是 ListView 的一部分。 这是一个xml文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textUser"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Slashdot"
android:textStyle="bold" />
<TextView
android:id="@+id/time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"/>
</LinearLayout>
<TextView
android:id="@+id/messageText"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
如果 TextView messageText 是几个字符而没有填满整行(比整行短),则该行不会显示为完整的可用宽度。它给我带来了几个问题:外观问题,当我尝试选择某行时出现问题,如果 messageText 只有几个字符长,我必须准确选择可用字符,而不仅仅是“单击”整行。
提前致谢
更新: 这些行看起来像这样:
用户 1 01:01:01 一些文字1
用户 2 01:01:01 一些文字2
代替:
用户 1 ---------------------------------------------- ----------------------------------------- 01:01:01 一些文字1
用户2---------------------------------------------- -------------------------------------------01:01:01 一些文字2
在第一种情况下,如果我想选择某行,我需要准确地“单击”“某些文本”。 我希望能够通过单击该行的任意位置来选择某行“单击”
【问题讨论】:
-
你如何为你的列表视图设置点击监听器?
-
你能发截图吗,XML没有明显的问题。
-
registerForContextMenu(myListView;
-
我没有足够的“声誉”来发布图片..
标签: android listview row adapter