Search in sources :

Example 1 with PullToRefreshExpandableListView

use of com.handmark.pulltorefresh.library.PullToRefreshExpandableListView in project Android-PullToRefresh by chrisbanes.

the class PullToRefreshExpandableListActivity method onCreate.

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_ptr_expandable_list);
    mPullRefreshListView = (PullToRefreshExpandableListView) findViewById(R.id.pull_refresh_expandable_list);
    // Set a listener to be invoked when the list should be refreshed.
    mPullRefreshListView.setOnRefreshListener(new OnRefreshListener<ExpandableListView>() {

        @Override
        public void onRefresh(PullToRefreshBase<ExpandableListView> refreshView) {
            // Do work to refresh the list here.
            new GetDataTask().execute();
        }
    });
    for (String group : mGroupStrings) {
        Map<String, String> groupMap1 = new HashMap<String, String>();
        groupData.add(groupMap1);
        groupMap1.put(KEY, group);
        List<Map<String, String>> childList = new ArrayList<Map<String, String>>();
        for (String string : mChildStrings) {
            Map<String, String> childMap = new HashMap<String, String>();
            childList.add(childMap);
            childMap.put(KEY, string);
        }
        childData.add(childList);
    }
    mAdapter = new SimpleExpandableListAdapter(this, groupData, android.R.layout.simple_expandable_list_item_1, new String[] { KEY }, new int[] { android.R.id.text1 }, childData, android.R.layout.simple_expandable_list_item_2, new String[] { KEY }, new int[] { android.R.id.text1 });
    setListAdapter(mAdapter);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) SimpleExpandableListAdapter(android.widget.SimpleExpandableListAdapter) Map(java.util.Map) HashMap(java.util.HashMap) PullToRefreshExpandableListView(com.handmark.pulltorefresh.library.PullToRefreshExpandableListView) ExpandableListView(android.widget.ExpandableListView)

Aggregations

ExpandableListView (android.widget.ExpandableListView)1 SimpleExpandableListAdapter (android.widget.SimpleExpandableListAdapter)1 PullToRefreshExpandableListView (com.handmark.pulltorefresh.library.PullToRefreshExpandableListView)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1