Code example for FragmentActivity

Methods: onRestoreInstanceState, setContentView

0
     *@see Activity#onRestoreInstanceState(Bundle) 
     */ 
    @Override 
    protected void onRestoreInstanceState(Bundle state) {
        ensureList(); 
        super.onRestoreInstanceState(state);
    } 
 
    /** 
     * Updates the screen state (current list and other views) when the 
     * content changes. 
     * 
     * @see Activity#onContentChanged() 
     */ 
    @Override 
    public void onContentChanged() { 
        super.onContentChanged(); 
        View emptyView = findViewById(android.R.id.empty);
        mList = (ExpandableListView)findViewById(android.R.id.list);
        if (mList == null) {
            throw new RuntimeException(
                    "Your content must have a ExpandableListView whose id attribute is " + 
                    "'android.R.id.list'"); 
        } 
        if (emptyView != null) {
            mList.setEmptyView(emptyView);
        } 
        mList.setOnChildClickListener(this);
        mList.setOnGroupExpandListener(this);
        mList.setOnGroupCollapseListener(this);
 
        if (mFinishedStart) {
            setListAdapter(mAdapter);
        } 
        mFinishedStart = true;
    } 
 
    /** 
     * Provide the adapter for the expandable list. 
     */ 
    public void setListAdapter(ExpandableListAdapter adapter) {
        synchronized (this) {
            ensureList(); 
            mAdapter = adapter;
            mList.setAdapter(adapter);
        } 
    } 
 
    /** 
     * Get the activity's expandable list view widget.  This can be used to get the selection, 
     * set the selection, and many other useful functions. 
     * 
     * @see ExpandableListView 
     */ 
    public ExpandableListView getExpandableListView() {
        ensureList(); 
        return mList;
    } 
 
    /** 
     * Get the ExpandableListAdapter associated with this activity's 
     * ExpandableListView. 
     */ 
    public ExpandableListAdapter getExpandableListAdapter() {
        return mAdapter;
    } 
 
    private void ensureList() { 
        if (mList != null) {
            return; 
        } 
        setContentView(android.R.layout.expandable_list_content);
    } 
 
    /** 
     * Gets the ID of the currently selected group or child. 
     *