ExpandableListView sample from Google

前端 未结 2 2022
独厮守ぢ
独厮守ぢ 2020-12-31 17:52

I just tried the current Google sample for ExpandableListiew:

This sample seem very simple and easy to use, but what I would like to do is to say that one of the cat

2条回答
  •  一生所求
    2020-12-31 18:06

    In general, if you want a specific area of your activity to be refreshed when you come back from another activity; you got to write in the onResume() method.

    Steps: 1 – In the Activity you want it to be refreshed, override the onResume() method:

    @Override
    protected void onResume() {
        super.onResume();
        // TODO: PUT YOUR REFRESH CODE IN HERE
    }
    

    2- You will need to refresh your Expandable Adapter.

    I suggest you take the same code you used to instantiate your expandable list and put it again, like follows:

    SimpleExpandableListAdapter expandableListAdapter =
        new SimpleExpandableListAdapter(
            this,
            YourPrentsList, // List of your parent 
            R.layout.parents_layout,    // Layout for the Parents
            new String[] { "groupKey" },    // Key in the Group Data maps to display
            new int[] { 1 },        
            childrenList,   // List of the children
            R.layout.childs_layout, // Layout of the children
            new String[] { "keys"}, 
            new int[] { 1}  
        );
    setListAdapter( expandableListAdapter );
    

    I hope this solves your concern... Thanks,

    Mohamed.

提交回复
热议问题