所以我即将做一个项目,其中它将包含类似任务的复选框(列表视图),在下面这将是一个评论部分(另一个列表视图)。我怎么可能做到这一点?在android中显示2个listviews的最佳方式是什么?
回答
您应该可以通过在布局中放置两个具有相同权重的ListView来实现这一目标。 (我也把一些标签的列表视图分开)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Tasks"
android:padding="5dp"
android:gravity="center" />
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/listView"
android:layout_weight="1" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Comments"
android:padding="5dp"
android:gravity="center" />
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/listView2"
android:layout_gravity="center_horizontal"
android:layout_weight="1" />
</LinearLayout>
这个布局会像滚动视图一样吗? – Wubeezy
每个ListView将独立滚动 –
使用2 Linearlayouts根布局(这里的LinearLayout)内。既要0.5 的列表视图,在这两种 设定的权重有match_parent 的heigth - 完成
,所以如果它们由于其中的项目数量不同而具有不同的高度,它将看起来像正常,就像整个屏幕会像滚动视图一样? – Wubeezy
- 1. 在android中执行多个listviews的最佳方式是什么?
- 2. 什么是在Android中显示信息的最佳方式
- 3. 在PyQt4中显示视频流的最佳方式是什么?
- 4. 在Angular2中显示进度条的最佳方式是什么?
- 5. 在Laravel 5.1中显示菜单的最佳方式是什么?
- 6. 什么是在ASP.NET中显示评论的最佳方式?
- 7. 什么是在Web表单中显示XML的最佳方式?
- 8. 什么是在网格中显示“焦点”的最佳方式?
- 9. 在Express.js中显示Flash消息的最佳方式是什么?
- 10. 在ASP.NET中显示缩略图的最佳方式是什么?
- 11. 在recyclerView中显示html的最佳方式是什么?
- 12. 在Flex中显示HTML的最佳方式是什么?
- 13. 什么是在Android应用程序中显示横幅的最佳方式?
- 14. 什么是在网站上显示图像的最佳方式?
- 15. 在TextField后面显示文本的最佳方式是什么?
- 16. 在Espresso 2中使用LESS的最佳方式是什么?
- 17. 在iPhone sdk中显示多少个屏幕的最佳方式是什么?
- 18. 什么是在单个页面上显示多个网站的最佳方式?
- 19. 在android中显示图像的最佳视图是什么?
- 20. 使用Cocoa显示列表的最佳方式是什么?
- 21. 处理多台显示器的最佳方式是什么?
- 22. 处理视网膜显示的最佳方式是什么?
- 23. 什么是通过java显示html的最佳方式
- 24. AngularJs - 动态显示按钮的最佳方式是什么?
- 25. 显示下拉菜单的最佳方式是什么?
- 26. 什么是通过PHP显示SQL表的最佳方式?
- 27. 什么是显示语言选择的最佳方式?
- 28. 显示关联数据的最佳方式是什么?
- 29. 什么是显示嵌套评论的最佳方式?
- 30. 组合(合并)2个JSONObjects的最佳方式是什么?
你可以简单地通过使用LinearLayouts屏幕分成两个ListView的。 但个人而言,我建议您在评论部分使用对话框视图,这与Facebook在其应用中执行的操作是一致的。 – Rachit