Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- expListAdapter = new MyListAdapter(this, createGroupList(), createGroupList());
- setListAdapter( expListAdapter );
- private List createGroupList() {
- ArrayList result = new ArrayList();
- for (int i=0; i < Liste.AnzahlElemente(); i++) { //
- result.add(Liste.getSize(i).getGroupString());
- }
- return result;
- }
- private List createChildList() {
- ArrayList result = new ArrayList();
- for(int i=0; i < Liste.getSize(); i++) {
- ArrayList secList = new ArrayList();
- for( int n = 1 ; n <= 3 ; n++ ) {
- if (Liste.getElement(i).getChildString(n).length() != 0){
- secList.add( "- " + Liste.getElement(i).getChildString(n));
- }
- }
- result.add( secList );
- }
- return result;
- }
- Collections.sort(Liste.getListe(), new NameComparator());
- expListAdapter.notifyDataSetInvalidated();
- //expListAdapter.notifyDataSetChanged(); //same effect as notifyDataSetInvalided
- public class NameComparator implements Comparator<ToDoElement>{
- public int compare(ToDoElement item1, ToDoElement item2) {
- return item1.getGroupString().compareTo(item2.getGroupString());
- }
- }
- public class MyListAdapter extends BaseExpandableListAdapter{
- private ArrayList<String> ueberschriften;
- private ArrayList<ArrayList<String>> stichpunkte;
- public MyListAdapter(Context context, List _ueberschriften, List _stichpunkte) {
- this.ueberschriften = (ArrayList)_ueberschriften;
- this.stichpunkte = (ArrayList)_stichpunkte;
- inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- }
- // [...] some other methods
- public void update(List _GroupStrings, List _ChildStrings) {
- GroupStrings = (ArrayList<String>) _GroupStrings;
- ChildStrings = (ArrayList<ArrayList<String>>) _ChildStrings;
- }
- }
- Collections.sort(Liste.getListe(), new NameComparator());
- expListAdapter.update(createGroupList(), createChildList());
- expListAdapter.notifyDataSetChanged();
Add Comment
Please, Sign In to add comment