| Author |
how can we view the two lists on a single display???
|
neelima kant
Greenhorn
Joined: Sep 17, 2010
Posts: 20
|
|
xml code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android rientation="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>
|
 |
Swastik Dey
Ranch Hand
Joined: Jan 08, 2009
Posts: 1188
|
|
try this
|
Swastik
|
 |
neelima kant
Greenhorn
Joined: Sep 17, 2010
Posts: 20
|
|
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
Joined: Sep 17, 2010
Posts: 20
|
|
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
Ranch Hand
Joined: Jan 08, 2009
Posts: 1188
|
|
xml
java
|
 |
neelima kant
Greenhorn
Joined: Sep 17, 2010
Posts: 20
|
|
thanks swastik
again a query ....if i want to add separator between these two lists den how can i acheive this???.
|
 |
Swastik Dey
Ranch Hand
Joined: Jan 08, 2009
Posts: 1188
|
|
Add a view between two lists
|
 |
neelima kant
Greenhorn
Joined: Sep 17, 2010
Posts: 20
|
|
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
Ranch Hand
Joined: Jan 08, 2009
Posts: 1188
|
|
|
By checkable do mean you want checkboxes besides the text in list box?
|
 |
neelima kant
Greenhorn
Joined: Sep 17, 2010
Posts: 20
|
|
|
yes with checkboxes....my code is not working properly.
|
 |
neelima kant
Greenhorn
Joined: Sep 17, 2010
Posts: 20
|
|
|
i want to made the second list with multiple choices...using choice_mode_multiple.....
|
 |
Swastik Dey
Ranch Hand
Joined: Jan 08, 2009
Posts: 1188
|
|
try this
|
 |
neelima kant
Greenhorn
Joined: Sep 17, 2010
Posts: 20
|
|
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
Ranch Hand
Joined: Jan 08, 2009
Posts: 1188
|
|
try this once
|
 |
neelima kant
Greenhorn
Joined: Sep 17, 2010
Posts: 20
|
|
|
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
Ranch Hand
Joined: Jan 08, 2009
Posts: 1188
|
|
I hope this solves your purpose
|
 |
neelima kant
Greenhorn
Joined: Sep 17, 2010
Posts: 20
|
|
|
yes it works properly now thanks. can you tell me what is the significance of using tablelayout in xml file.
|
 |
Swastik Dey
Ranch Hand
Joined: Jan 08, 2009
Posts: 1188
|
|
|
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
Joined: Sep 17, 2010
Posts: 20
|
|
|
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
Joined: Sep 17, 2010
Posts: 20
|
|
|
how i made the association among two lists if i considered that first list containing the selected components of second list....
|
 |
Swastik Dey
Ranch Hand
Joined: Jan 08, 2009
Posts: 1188
|
|
|
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.
|
 |
 |
|
|
subject: how can we view the two lists on a single display???
|
|
|