Example usage for android.widget ExpandableListView ExpandableListView

List of usage examples for android.widget ExpandableListView ExpandableListView

Introduction

In this page you can find the example usage for android.widget ExpandableListView ExpandableListView.

Prototype

public ExpandableListView(Context context) 

Source Link

Usage

From source file:cn.newgxu.android.bbs.ui.ForumsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    this.listView = new ExpandableListView(getActivity());
    this.app = (BBSApplication) getActivity().getApplication();

    this.mAdapter = new SimpleExpandableListAdapter(getActivity(), ForumsProvider.AREAS,
            android.R.layout.simple_expandable_list_item_1,
            new String[] { ForumsProvider.NAME, ForumsProvider.ABOUT },
            new int[] { android.R.id.text1, android.R.id.text2 }, ForumsProvider.FORUMS, R.layout.forum_row,
            new String[] { ForumsProvider.NAME, ForumsProvider.ABOUT },
            new int[] { android.R.id.text1, android.R.id.text2 });

    listView.setAdapter(mAdapter);/*ww w  .j  av  a2  s .c o  m*/
    listView.setOnChildClickListener(this);
    listView.setTextFilterEnabled(true);

    return listView;
}

From source file:com.todoroo.astrid.activity.ExpandableListFragment.java

/**
 * Provide default implementation to return a simple list view.  Subclasses
 * can override to replace with their own layout.  If doing so, the
 * returned view hierarchy <em>must</em> have a ListView whose id
 * is {@link android.R.id#list android.R.id.list} and can optionally
 * have a sibling view id {@link android.R.id#empty android.R.id.empty}
 * that is to be shown when the list is empty.
 *
 * <p>If you are overriding this method with your own custom content,
 * consider including the standard layout {@link android.R.layout#list_content}
 * in your layout file, so that you continue to retain all of the standard
 * behavior of ListFragment.  In particular, this is currently the only
 * way to have the built-in indeterminant progress state be shown.
 *//* w  w  w  .ja v a  2  s . c  o  m*/
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    FrameLayout root = new FrameLayout(getActivity());

    TextView tv = new TextView(getActivity());
    tv.setId(INTERNAL_EMPTY_ID);
    tv.setGravity(Gravity.CENTER);
    root.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    ExpandableListView lv = new ExpandableListView(getActivity());
    lv.setId(android.R.id.list);
    lv.setDrawSelectorOnTop(false);
    root.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    ListView.LayoutParams lp = new ListView.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT);
    root.setLayoutParams(lp);

    return root;
}

From source file:de.memorian.ps4trophaen.util.ExpandableListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (savedInstanceState != null) {
        lastExpandedPosition = savedInstanceState.getInt(LAST_EXP_POS, -1);
    }/*from   w  w  w . j a va 2s . c o  m*/
    FrameLayout root = new FrameLayout(getActivity());

    FrameLayout lframe = new FrameLayout(getActivity());
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);

    TextView tv = new TextView(getActivity());
    tv.setId(INTERNAL_EMPTY_ID);
    tv.setGravity(Gravity.CENTER);
    lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    ExpandableListView lv = new ExpandableListView(getActivity());
    lv.setId(android.R.id.list);
    lv.setDrawSelectorOnTop(false);
    lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    ListView.LayoutParams lp = new ListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    root.setLayoutParams(lp);

    return root;
}

From source file:br.unb.mobileMedia.core.view.ExpandableListFragment.java

/**
 * Provide default implementation to return a simple list view.  Subclasses
 * can override to replace with their own layout.  If doing so, the
 * returned view hierarchy <em>must</em> have a ListView whose id
 * is {@link android.R.id#list android.R.id.list} and can optionally
 * have a sibling view id {@link android.R.id#empty android.R.id.empty}
 * that is to be shown when the list is empty.
 * <p/>/*from  w w  w . j a  v a  2 s. c o  m*/
 * <p>If you are overriding this method with your own custom content,
 * consider including the standard layout {@link android.R.layout#list_content}
 * in your layout file, so that you continue to retain all of the standard
 * behavior of ListFragment.  In particular, this is currently the only
 * way to have the built-in indeterminant progress state be shown.
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    FrameLayout root = new FrameLayout(getActivity());

    FrameLayout lframe = new FrameLayout(getActivity());
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);

    TextView tv = new TextView(getActivity());
    tv.setId(INTERNAL_EMPTY_ID);
    tv.setGravity(Gravity.CENTER);
    lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    ExpandableListView lv = new ExpandableListView(getActivity());
    lv.setId(android.R.id.list);
    lv.setDrawSelectorOnTop(false);
    lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    ListView.LayoutParams lp = new ListView.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT);
    root.setLayoutParams(lp);

    return root;
}

From source file:libraries.stackoverflow.ExpandableListFragment.java

/**
 * Provide default implementation to return a simple list view. Subclasses
 * can override to replace with their own layout. If doing so, the returned
 * view hierarchy <em>must</em> have a ListView whose id is
 * {@link android.R.id#list android.R.id.list} and can optionally have a
 * sibling view id {@link android.R.id#empty android.R.id.empty} that is to
 * be shown when the list is empty.//from   w  w  w .j  a v a  2  s  .  c om
 * <p/>
 * <p>
 * If you are overriding this method with your own custom content, consider
 * including the standard layout {@link android.R.layout#list_content} in
 * your layout file, so that you continue to retain all of the standard
 * behavior of ListFragment. In particular, this is currently the only way
 * to have the built-in indeterminant progress state be shown.
 */
@SuppressWarnings("deprecation")
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    FrameLayout root = new FrameLayout(getActivity());

    FrameLayout lframe = new FrameLayout(getActivity());
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);

    TextView tv = new TextView(getActivity());
    tv.setId(INTERNAL_EMPTY_ID);
    tv.setGravity(Gravity.CENTER);
    lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    ExpandableListView lv = new ExpandableListView(getActivity());
    lv.setId(android.R.id.list);
    lv.setDrawSelectorOnTop(false);
    lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    ListView.LayoutParams lp = new ListView.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT);
    root.setLayoutParams(lp);

    return root;
}

From source file:com.aboveware.abovegame.expandable.ExpandableListFragment.java

/**
 * Provide default implementation to return a simple list view. Subclasses can
 * override to replace with their own layout. If doing so, the returned view
 * hierarchy <em>must</em> have a ListView whose id is
 * {@link android.R.id#list android.R.id.list} and can optionally have a
 * sibling view id {@link android.R.id#empty android.R.id.empty} that is to be
 * shown when the list is empty.//w  ww.  ja v a  2 s .  c om
 * <p/>
 * <p>
 * If you are overriding this method with your own custom content, consider
 * including the standard layout {@link android.R.layout#list_content} in your
 * layout file, so that you continue to retain all of the standard behavior of
 * AbsListFragment. In particular, this is currently the only way to have the
 * built-in indeterminant progress state be shown.
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    FrameLayout root = new FrameLayout(getActivity());

    FrameLayout lframe = new FrameLayout(getActivity());
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);

    TextView tv = new TextView(getActivity());
    tv.setId(INTERNAL_EMPTY_ID);
    tv.setGravity(Gravity.CENTER);
    lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    ExpandableListView lv = new ExpandableListView(getActivity());
    lv.setId(android.R.id.list);
    lv.setDrawSelectorOnTop(false);
    lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    ListView.LayoutParams lp = new ListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    root.setLayoutParams(lp);

    return root;
}

From source file:com.github.jvanhie.discogsscrobbler.SearchFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    mList = new ExpandableListView(getActivity());
    mList.setAdapter(mAdapter);/*from ww w  .j av a 2 s  .  co  m*/

    mList.setOnGroupClickListener(new GroupClickHandler());

    mList.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
        @Override
        public boolean onChildClick(ExpandableListView expandableListView, View view, final int i, int i2,
                long l) {
            if (l == 0) {
                //it's a loader (yes, hackish afterthought) get the necessary data from it
                DiscogsSearchLoader loader = (DiscogsSearchLoader) mAdapter.getChild(i, i2);
                mCallbacks.setRefreshVisible(true);
                if (loader.parenttype.equals("artist")) {
                    mDiscogs.getArtistReleases(loader.parentid, loader.page,
                            new Discogs.DiscogsDataWaiter<List<DiscogsSearchRelease>>() {
                                @Override
                                public void onResult(boolean success, List<DiscogsSearchRelease> data) {
                                    if (success) {
                                        mAdapter.addChildren(i, data);
                                    }
                                    mCallbacks.setRefreshVisible(false);
                                }
                            });
                } else if (loader.parenttype.equals("label")) {
                    mDiscogs.getLabelReleases(loader.parentid, loader.page,
                            new Discogs.DiscogsDataWaiter<List<DiscogsSearchRelease>>() {
                                @Override
                                public void onResult(boolean success, List<DiscogsSearchRelease> data) {
                                    if (success) {
                                        mAdapter.addChildren(i, data);
                                    }
                                    mCallbacks.setRefreshVisible(false);
                                }
                            });
                } else if (loader.parenttype.equals("master")) {
                    mDiscogs.getMasterReleases(loader.parentid, loader.page,
                            new Discogs.DiscogsDataWaiter<List<DiscogsSearchRelease>>() {
                                @Override
                                public void onResult(boolean success, List<DiscogsSearchRelease> data) {
                                    if (success) {
                                        mAdapter.addChildren(i, data);
                                    }
                                    mCallbacks.setRefreshVisible(false);
                                }
                            });
                }
            } else {
                //normal release selected
                onItemSelected(l);
            }

            return false;
        }
    });

    //create superframe for adding list and empty view
    FrameLayout superFrame = new FrameLayout(getActivity());
    FrameLayout.LayoutParams layoutparams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    superFrame.setLayoutParams(layoutparams);
    View emptyView = inflater.inflate(R.layout.fragment_empty, container, false);
    mEmptyHeading = ((TextView) emptyView.findViewById(R.id.empty_heading));
    mEmptyHeading.setText("Start searching Discogs");
    mEmptyText = ((TextView) emptyView.findViewById(R.id.empty_text));
    mEmptyText.setText("Enter a query or scan a barcode");

    if (mDiscogs == null)
        mDiscogs = Discogs.getInstance(getActivity());

    mList.setGroupIndicator(null);

    superFrame.addView(emptyView);
    mList.setEmptyView(emptyView);
    superFrame.addView(mList);

    return superFrame;
}

From source file:hcm.ssj.creator.dialogs.AddDialog.java

/**
 * @param savedInstanceState Bundle/*from   w  w w  . j  av a2  s. co  m*/
 * @return Dialog
 */
@Override
@NonNull
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (hashMap == null) {
        throw new RuntimeException();
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(titleMessage);
    builder.setPositiveButton(R.string.str_ok, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            boolean written = false;
            if (hashMap != null) {
                int x = 0;
                for (Map.Entry<String, ArrayList<Class>> entry : hashMap.entrySet()) {
                    int y = 0;
                    ArrayList<Class> arrayList = entry.getValue();
                    for (Class clazz : arrayList) {
                        if (itemState[x][y]) {
                            written = true;
                            Linker.getInstance().add(Builder.instantiate(clazz));
                        }
                        y++;
                    }
                    x++;
                }
            }
            for (Listener listener : alListeners) {
                if (written) {
                    listener.onPositiveEvent(null);
                } else {
                    listener.onNegativeEvent(null);
                }
            }
        }
    });
    builder.setNegativeButton(R.string.str_cancel, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            for (Listener listener : alListeners) {
                listener.onNegativeEvent(null);
            }
        }
    });
    //set up input
    listView = new ExpandableListView(getContext());
    listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
    setListListeners();
    if (hashMap != null && hashMap.size() > 0) {
        ListAdapter listAdapter = new ListAdapter(getContext(), hashMap);
        listView.setAdapter(listAdapter);
    } else {
        listView.setAdapter(
                new ArrayAdapter<>(getContext(), android.R.layout.simple_list_item_multiple_choice));
    }
    builder.setView(listView);
    return builder.create();
}

From source file:com.frostwire.android.gui.views.ExpandableListFragment.java

/**
 * Provide default implementation to return a simple list view.  Subclasses
 * can override to replace with their own layout.  If doing so, the
 * returned view hierarchy <em>must</em> have a ListView whose id
 * is {@link android.R.id#list android.R.id.list} and can optionally
 * have a sibling view id {@link android.R.id#empty android.R.id.empty}
 * that is to be shown when the list is empty.
 * /*from  w  w  w .ja  v a2 s.c om*/
 * <p>If you are overriding this method with your own custom content,
 * consider including the standard layout {@link android.R.layout#list_content}
 * in your layout file, so that you continue to retain all of the standard
 * behavior of ListFragment.  In particular, this is currently the only
 * way to have the built-in indeterminant progress state be shown.
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context context = getActivity();

    FrameLayout root = new FrameLayout(context);

    // ------------------------------------------------------------------

    LinearLayout pframe = new LinearLayout(context);
    pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
    pframe.setOrientation(LinearLayout.VERTICAL);
    pframe.setVisibility(View.GONE);
    pframe.setGravity(Gravity.CENTER);

    ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge);
    pframe.addView(progress, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    root.addView(pframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    // ------------------------------------------------------------------

    FrameLayout lframe = new FrameLayout(context);
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);

    TextView tv = new TextView(getActivity());
    tv.setId(INTERNAL_EMPTY_ID);
    tv.setGravity(Gravity.CENTER);
    lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    ExpandableListView lv = new ExpandableListView(getActivity());
    lv.setId(android.R.id.list);
    lv.setDrawSelectorOnTop(false);
    lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    // ------------------------------------------------------------------

    root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    return root;
}

From source file:id.nci.stm_9.ExpandableListFragment.java

/**
 * Provide default implementation to return a simple list view. Subclasses can override to
 * replace with their own layout. If doing so, the returned view hierarchy <em>must</em> have a
 * ListView whose id is {@link android.R.id#list android.R.id.list} and can optionally have a
 * sibling view id {@link android.R.id#empty android.R.id.empty} that is to be shown when the
 * list is empty.//from  ww  w. j a  v a 2s.c  o  m
 * 
 * <p>
 * If you are overriding this method with your own custom content, consider including the
 * standard layout {@link android.R.layout#list_content} in your layout file, so that you
 * continue to retain all of the standard behavior of ListFragment. In particular, this is
 * currently the only way to have the built-in indeterminant progress state be shown.
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context context = getActivity();

    FrameLayout root = new FrameLayout(context);

    // ------------------------------------------------------------------

    LinearLayout pframe = new LinearLayout(context);
    pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
    pframe.setOrientation(LinearLayout.VERTICAL);
    pframe.setVisibility(View.GONE);
    pframe.setGravity(Gravity.CENTER);

    ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge);
    pframe.addView(progress, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    root.addView(pframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    // ------------------------------------------------------------------

    FrameLayout lframe = new FrameLayout(context);
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);

    TextView tv = new TextView(getActivity());
    tv.setId(INTERNAL_EMPTY_ID);
    tv.setGravity(Gravity.CENTER);
    lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    ExpandableListView lv = new ExpandableListView(getActivity());
    lv.setId(android.R.id.list);
    lv.setDrawSelectorOnTop(false);
    lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    // ------------------------------------------------------------------

    root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    return root;
}