我正在尝试将ListView项目放入ListView中.目前它们是可点击的(请参阅我的屏幕截图),但它们只能在文本占用的矩形内单击.
我正在使用protected void onListItemClick(ListView l, View v, int position, long id) {
可点击列表项.
这是我的list.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ListView android:id="@+id/android:list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/android:empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/no_favorites"/>
Run Code Online (Sandbox Code Playgroud)
和我的row.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView android:id="@+id/artist"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/songtitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_alignParentRight="true"/>
<TextView android:id="@+id/album"
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_alignParentRight="true"/>
<TextView android:id="@+id/playtime"
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_alignParentRight="true"/>
<TextView android:id="@+id/playlistnum"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_alignParentRight="true"
android:visibility="gone" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
而这里的截图例子:(新用户不得发表图片... ...叽有一个超链接!)
在list.xml中,Listview具有android:layout_width ="fill_parent",因此它应该是屏幕的整个宽度.(row.xml中的所有项目也是width ="fill_parent".)我缺少什么?
JLB*_*JLB 11
list.xml中的TextView需要设置为fill_parent.然后,选择将适合父ListView的宽度.
android:layout_width="wrap_content"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2969 次 |
| 最近记录: |