質問

i have an ExpendableListView with 5 childs for each groupView. But when i whants to add more than one groupView to the list, nothing works...

the childView are not under the respective groupView(5 per groupView), but they will be added additional to the other childViews from other groupViews(10 per groupView if ther are 2 groupViews in the list, 15 if ther are 3...). This means all available childviews are in everyGroupVeiw element Can anybody help me? I am sorry for my bad english.

I think the mistake is in the Hashmap constellation, but i dont get it...

This is how i set the adapter, i am using expendableBaseAdapter like in this tut: http://www.androidhive.info/2013/07/android-expandable-list-view-tutorial/

public void prepareListData(){
    dataChild = new HashMap<String, List<String>>();
    dataHead = new ArrayList<String>();

    List<String> uebung = new ArrayList<String>();


    for(int i=0;i<list.size();i++){
        //set Head
        dataHead.add(list.get(i).getName());
        //set Childs

        uebung.add(String.valueOf(list.get(i).getGewicht()));
        uebung.add(String.valueOf(list.get(i).getWdhlg()));
        uebung.add(String.valueOf(list.get(i).getSaetze()));
        uebung.add(String.valueOf(list.get(i).getKommentar()));
        uebung.add(String.valueOf(list.get(i).getEinheit()));

        dataChild.put(dataHead.get(i), uebung);
    }
adapt = new ListViewAdapterUebungH(getActivity(), dataHead, dataChild);
        explistView.setAdapter(adapt);
役に立ちましたか?

解決

Okay i have found my mistake, i have to create the new Listuebung in the for-loop. Because of this mistake, the informations was added to the listfor every new head element

List<String> uebung;

    //size is the filled list from Trainingsplansammlung
    for(int i=0;i<list.size();i++){
        uebung = new ArrayList<String>();
        //set Head
        dataHead.add(list.get(i).getName());
        //set Childs

        uebung.add(String.valueOf(list.get(i).getGewicht()));
        uebung.add(String.valueOf(list.get(i).getWdhlg()));
        uebung.add(String.valueOf(list.get(i).getSaetze()));
        uebung.add(String.valueOf(list.get(i).getKommentar()));
        uebung.add(String.valueOf(list.get(i).getEinheit()));

        dataChild.put(dataHead.get(i), uebung);
    }
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top