开发者

How to display two lists from two tables in single view in Android

The Notepad example on android developer is good for a single list, but I want two lists drawing from two tables in a single view. Can anyone expan开发者_如何学编程d on how to implement something like this?

I'm wondering about how many adapters I'll need. Can I manage two lists in a single ListActivity?


Why not implement as a Relative Layout instead of the Linear Layout in the tutorial. A linear layout only allows objects to be above and below each other while Relative Layout allows for more freedom.

Use

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

To put things next to each other. Mess with padding and spacing to get a good effect (note using both at the same time causes a crash so be sure to just use one).

Also there is

android:layout_alignLeft
android:layout_alignRight

but I'm just in the process of working it out.

And here we are why not have some example code

<?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>

Sorry if its a little messy

EDIT:

About the list adapters I would think it would be best that you use two adapters and implement them in separate frame views or something. It may also be worth looking into fragments but they are horrible if you ask me.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜