• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how can we view the two lists on a single display???

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
xml code


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="198px">
</ListView>
<ListView
android:id="@+id/ListView01"
android:layout_width="192px"
android:layout_height="215px">
</ListView>
<ListView
android:id="@+id/ListView02"
android:layout_width="192px"
android:layout_height="215px">
</ListView>

</LinearLayout>
 
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try this
 
neelima kant
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

setListAdapter(new ArrayAdapter<String>(this,layout.main,
id.ScrollView01, mStrings));

ListView cities = (ListView) findViewById(R.id.ListView02);

ArrayAdapter<String> aa = new ArrayAdapter<String>(this, layout.main,
id.ListView02, mStrings2);

cities.setAdapter(aa);



its not working properly, i add the sample code of my problem please check it out.
 
neelima kant
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
package com.example.hellotwolistviews;

import android.app.ListActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class HelloTwoListViews extends ListActivity {

private String[] mStrings = {
"Abbaye de Belloc", "Abbaye du Mont des Cats", "Abertam",
"Abondance", "Ackawi",
"Acorn", "Adelost", "Affidelice au Chablis", "Afuega'l",
"Pitu", "Airag", "Airedale",
"Aisy Cendre"};
private String[] mStrings2 = {"dsds", "qwqwqq", " dsdsdsd sdsdsds",
"dsdsds sdsds"};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

//setListAdapter for ListView 1
setListAdapter(new ArrayAdapter<String>(this, .layout.main,
.id.ScrollView01, mStrings));
//Code to display ListView 2
ListView cities = (ListView) findViewById(R.id.ListView02);
ArrayAdapter<String> aa = new ArrayAdapter<String>(this, .layout.main,
.id.ListView02, mStrings2);
cities.setAdapter(aa);


}

}

thats my sample code,please check it out.
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
xml


java
 
neelima kant
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks swastik

again a query ....if i want to add separator between these two lists den how can i acheive this???.
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Add a view between two lists

 
neelima kant
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if i want to make the second list checkable then i modify my code as

ArrayAdapter list2 = new ArrayAdapter<String>(
this, android.R.layout.simple_list_item_multiple_choice,mStrings2);
final ListView listView = getListView();

listView.setItemsCanFocus(false);
listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);

lv1.setAdapter(list1);
lv2.setAdapter(list2);


but its not working???
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By checkable do mean you want checkboxes besides the text in list box?
 
neelima kant
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes with checkboxes....my code is not working properly.
 
neelima kant
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i want to made the second list with multiple choices...using choice_mode_multiple.....
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try this
 
neelima kant
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks ....it work properly now.

if i want that the checked item of the second list move to the first list??? then how should i proceed??? i m taking my first list as empty list.
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try this once
 
neelima kant
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes thanks it work but i want that the items which i checked in second list it will not be there in the second list once i checked...... it will visible in first list only.
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I hope this solves your purpose
 
neelima kant
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes it works properly now thanks. can you tell me what is the significance of using tablelayout in xml file.
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As you have two lists, you need a scroll view to add the components. But on the other hand scroll view won't allow to add more than one component. So we took a table layout and added it to scroll view. Now the scroll view has only one component, and we added the list views to table layout which allows to add multiple components. I hope it helps you to understand the reason.
 
neelima kant
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
instead of using table layout i use framelayout in my application but it works not properly......we cant use framlelayout for this why???
 
neelima kant
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how i made the association among two lists if i considered that first list containing the selected components of second list....
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To be honest I am also pretty new on android, so won't be able to exactly tell you why frame layout didn't work. Coming to your second question there is no question of association, we are just resetting the adapters.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic