如何在Android中的单个视图中显示两个表中的两个列表

时间:2011-10-04 20:00:26

标签: android

The Notepad example on android developer适用于单个列表,但我希望在一个视图中从两个表中绘制两个列表。任何人都可以扩展如何实现这样的东西吗?

我想知道我需要多少个适配器。我可以在一个ListActivity中管理两个列表吗?

1 个答案:

答案 0 :(得分:1)

为什么不在教程中实现Relative Layout而不是线性布局。线性布局仅允许对象在彼此之上和之下,而相对布局允许更多自由。

使用

android:layout_toRightOf = ""
android:layout_toLeftOf = ""

把事情放在一起。 用填充和间距混合以获得良好的效果 (注意同时使用两者会导致崩溃,所以一定要使用一个)。

还有

android:layout_alignLeft
android:layout_alignRight

但我正在努力解决这个问题。

这就是为什么我们没有一些示例代码

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id = "@+id/layout">



<TextView
android:id = "@+id/RightFrame"  
android:layout_width="wrap_content" 
android:layout_height="fill_parent" 
android:text="hello right frame"
android:layout_alignParentRight = "true"/>




<TextView
android:id = "@+id/LeftFrame"
android:layout_width="wrap_content" 
android:layout_height="fill_parent" 
android:text="hello left frame"
android:layout_alignParentLeft = "true"/>



</RelativeLayout>

抱歉,如果它有点凌乱

编辑:

关于列表适配器我认为最好使用两个适配器并在单独的帧视图中实现它们。它也可能值得研究fragments,但如果你问我,它们会很糟糕。