0

Android 2.3.3

I have an activity where I display "Device's Contacts" in my custom view(imageview, 3 textboxes, checkbox) inside a ListView. What I want to do is, display two listviews with both showing alternate contacts (Splitting the listview into two) side by side. This is because, I want to utilize space on landscape mode of larger displays.

I haven't seen many questions on SO and somewhere I have read that, this approach will mess up scrolling of listviews and will get messy.

So, can someone explain why/how would it get messy and is there another way to use the space in larger displays in my scenario.

Thanks.

Vamsi Challa
  • 11,038
  • 31
  • 99
  • 149
  • 1
    You could do this, but each ListView should be in it's own container. – ooops May 24 '13 at 12:12
  • Okie... I will try it. Thank you. Do you have any example or link that would have implemented this? – Vamsi Challa May 24 '13 at 12:13
  • let me google it for you http://stackoverflow.com/questions/3405211/how-to-use-multiple-listviews-in-a-single-activity-on-android – ooops May 24 '13 at 12:18
  • @ooops I think your answer which was the first should be marked as an answer. Could you do your comment as an answer. – Vamsi Challa May 24 '13 at 12:28

2 Answers2

3

This sounds like exactly what the Building a Dynamic UI with Fragments android tutorial was designed to address.

As @ooops mentions you will need to put each ListView within its own container. In the tutorial I linked to, they accomplished this by using 2 Fragment instances, each that loaded different content. Whether you copy their example and use the <fragment> tab (admitidly I don't remember which API level that works on) or use a different container like a regular LinearLayout you should be able to acomplish this easily.

Rarw
  • 7,645
  • 3
  • 28
  • 46
  • @Vamsi Challa if you will follow this way, don't forget to add compatibility package to make this work on your 2.3.3 http://mobile.tutsplus.com/tutorials/android/android-compatibility-working-with-fragments/ – ooops May 24 '13 at 12:20
  • That's right - I just checked the on an atrix running 2.3.6. It works but you need the support library. – Rarw May 24 '13 at 12:22
0

You could do this, but each ListView should be in it's own container. For examlple How to use multiple listviews in a single activity on android?

But be aware that @Rarw is more correct in the way of good programming practice. Fragments are recommended for such purpose.

Community
  • 1
  • 1
ooops
  • 326
  • 2
  • 14