I am using a dynamic ListView which contains 3 buttons ,1 checkbox and a textview.I want that 1.) The user should be able to check only one checkbox from any row, if one is checked so other row's checkbox should be unchecked . 2.) text on button & textView is also generated dynamically via different ArrayLists so how can I use diff-2 arraylist in a single ListView.
3
-
When you try with a single arraylist does it work?Hades– Hades2011-05-02 11:39:33 +00:00Commented May 2, 2011 at 11:39
-
@Hades works with single arraylist but checkbox's problem is still thereArun Badole– Arun Badole2011-05-04 05:04:01 +00:00Commented May 4, 2011 at 5:04
-
Use a hashmap to maintain what has been already clicked, if it is clicked then set the checkbox to ticked, if it's not then untick it. You have to do this in the getview method in the listview.Hades– Hades2011-05-04 05:09:29 +00:00Commented May 4, 2011 at 5:09
Add a comment
|
2 Answers
Craete a class E(You can rename as you want) like this
import java.util.ArrayList;
public class E {
private ArrayList<Object> list1;
private ArrayList<Object> list2;
/**
* @param list1 the list1 to set
*/
public void setList1(ArrayList<Object> list1) {
this.list1 = list1;
}
/**
* @return the list1
*/
public ArrayList<Object> getList1() {
return list1;
}
/**
* @param list2 the list2 to set
*/
public void setList2(ArrayList<Object> list2) {
this.list2 = list2;
}
/**
* @return the list2
*/
public ArrayList<Object> getList2() {
return list2;
}
}
Now here is your ArrayList which uses multiple ArrayList
ArrayList<E> custom=new ArrayList<E>();
Hope this will help you.
2 Comments
Arun Badole
Thanks for your reply but I solved my second problem my own. Still one to go
Tanmay Mandal
Then post your solution for other people's help.
Merge the two ArrayLists into a single ArrayList and set it as the adapter.
1 Comment
Arun Badole
but the problem is this I have to use different-2 ArrayList for different Views say 1 for textview 2 for button1 3 for button2 n so on. Plz Help me