Example usage for android.widget ExpandableListView setAdapter

List of usage examples for android.widget ExpandableListView setAdapter

Introduction

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

Prototype

public void setAdapter(ExpandableListAdapter adapter) 

Source Link

Document

Sets the adapter that provides data to this view.

Usage

From source file:com.chatwing.whitelabel.fragments.BaseExpandableListFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    mProgressView = view.findViewById(R.id.progress_container);
    mContentView = view.findViewById(R.id.content_container);
    TextView emptyView = (TextView) view.findViewById(android.R.id.empty);
    ExpandableListView listView = (ExpandableListView) view.findViewById(android.R.id.list);
    mAdapter = constructAdapter();// ww  w  . j  a  va  2 s . co  m

    emptyView.setText(getEmptyTextId());
    listView.setEmptyView(emptyView);
    listView.setOnChildClickListener(this);
    listView.setAdapter(mAdapter);
}

From source file:com.fastbootmobile.encore.app.fragments.SearchFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View root = inflater.inflate(R.layout.fragment_search, container, false);
    assert root != null;

    mLoadingBar = (ProgressBar) root.findViewById(R.id.pbLoading);

    mAdapter = new SearchAdapter();

    ExpandableListView listView = (ExpandableListView) root.findViewById(R.id.expandablelv_search);
    listView.setAdapter(mAdapter);
    listView.setGroupIndicator(null);/* www  .ja v  a2  s .co  m*/
    for (int i = 0; i < 4; i++) {
        listView.expandGroup(i, false);
    }

    listView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
        @Override
        public boolean onChildClick(ExpandableListView expandableListView, View view, int i, int i2, long l) {
            if (mSearchResults != null) {
                switch (i) {
                case SearchAdapter.ARTIST:
                    onArtistClick(i2, view);
                    break;

                case SearchAdapter.ALBUM:
                    onAlbumClick(i2, view);
                    break;

                case SearchAdapter.SONG:
                    onSongClick(i2);
                    break;

                case SearchAdapter.PLAYLIST:
                    onPlaylistClick(i2, view);
                    break;

                default:
                    Log.e(TAG, "Unknown child group id " + i);
                    break;
                }

                return true;
            } else {
                return false;
            }
        }
    });

    // Restore previous search results, in case we're rotating
    if (mSearchResults != null) {
        mAdapter.appendResults(mSearchResults);
        mAdapter.notifyDataSetChanged();
    }

    return root;
}

From source file:com.github.michalbednarski.intentslab.AppComponentsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    FragmentActivity activity = getActivity();
    FrameLayout frameLayout = new FrameLayout(activity);
    FrameLayout.LayoutParams stretch = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.MATCH_PARENT);
    FrameLayout.LayoutParams center = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT,
            FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.CENTER);

    final ExpandableListView expandableListView = new ExpandableListView(activity);
    expandableListView.setAdapter(this);
    expandableListView.setOnChildClickListener(this);
    expandableListView.setLayoutParams(stretch);
    frameLayout.addView(expandableListView);

    final TextView emptyView = new TextView(activity);
    emptyView.setText(activity.getString(R.string.no_components));
    emptyView.setLayoutParams(center);// w w w .ja  v a 2 s. c  om
    frameLayout.addView(emptyView);

    expandableListView.setEmptyView(emptyView);

    return frameLayout;
}

From source file:org.openbmap.activities.DialogPreferenceMaps.java

@Override
protected void onBindDialogView(View v) {
    super.onBindDialogView(v);
    groups = new SparseArray<>();
    ExpandableListView listView = (ExpandableListView) v.findViewById(R.id.list);
    mAdapter = new DialogPreferenceMapsListAdapter(getContext(), groups, this);
    listView.setAdapter(mAdapter);

    if (checkDialog == null || !checkDialog.isShowing()) {
        checkDialog = new ProgressDialog(getContext());
    }//from  www. j  ava2s.  com
    // retrieve online maps
    GetAvailableMapsTask data = new GetAvailableMapsTask();
    data.execute();
}

From source file:org.openbmap.activities.DialogPreferenceCatalogs.java

@Override
protected void onBindDialogView(View v) {
    super.onBindDialogView(v);
    groups = new SparseArray<>();
    ExpandableListView listView = (ExpandableListView) v.findViewById(R.id.list);
    mAdapter = new DialogPreferenceCatalogsListAdapter(getContext(), groups, this);
    listView.setAdapter(mAdapter);

    if (checkDialog == null || !checkDialog.isShowing()) {
        checkDialog = new ProgressDialog(getContext());
    }//  www  .  j  a va  2  s.  c  o m
    // retrieve online Catalogs
    GetAvailableCatalogsTask data = new GetAvailableCatalogsTask();
    data.execute();
}

From source file:com.kaproduction.malibilgiler.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    coordinatorLayoutMainActivity = (CoordinatorLayout) findViewById(R.id.coordinatorLayoutMainActivity);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);//  www.j av  a 2  s.  c  om
    getSupportActionBar().setIcon(R.mipmap.ic_launcher1);

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar,
            R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();
    //Deneme Yourum Yazildi......
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    expandableListView = (ExpandableListView) findViewById(R.id.exp_list);
    mCategory = ExpandableListViewData.getInfo();
    mlist = new ArrayList<String>(mCategory.keySet());
    adapter = new ExpandableListViewAdapter(this, mCategory, mlist);
    expandableListView.setAdapter(adapter);
    expandableListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
        @Override
        public boolean onChildClick(ExpandableListView expandableListView, View view, int parent, int child,
                long l) {
            String heading = (String) adapter.getGroup(parent);
            String message = (String) adapter.getChild(parent, child);
            alertDialog(heading, message);
            // Toast.makeText(getApplicationContext(), result, Toast.LENGTH_LONG).show();
            return true;
        }
    });
    expandableListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> adapterView, View view, int position, long id) {
            if (ExpandableListView.getPackedPositionType(id) == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
                int groupPosition = ExpandableListView.getPackedPositionGroup(id);
                int childPosition = ExpandableListView.getPackedPositionChild(id);
                String text = (String) adapter.getChild(groupPosition, childPosition);
                String heading = (String) adapter.getGroup(groupPosition);
                alertDialogForClipboard(heading, text);
            }

            return true;
        }
    });

}

From source file:can.yrt.onebusaway.RouteInfoListFragment.java

public void setListAdapter(SimpleExpandableListAdapter adapter) {
    ExpandableListView list = (ExpandableListView) getListView();

    if (list != null) {
        list.setAdapter(adapter);
        setListShown(true);/* www.  j  a  v  a  2  s  . c  o m*/
    }
}

From source file:simonlang.coastdove.usagestatistics.ui.app_usage_data_details.DataEntryListFragment.java

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    this.loaderID = 300;

    // Progress bar while the list loads
    this.progressBar = new ProgressBar(getActivity());
    this.progressBar.setVisibility(View.VISIBLE);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    layoutParams.gravity = Gravity.CENTER;
    layoutParams.weight = 2;//from  ww  w .j a  v  a  2s. c om
    this.progressBar.setLayoutParams(layoutParams);
    this.progressBar.setIndeterminate(true);

    ExpandableListView elv = (ExpandableListView) getView().findViewById(android.R.id.list);
    elv.setEmptyView(this.progressBar);
    addProgressBarToViewGroup();

    AppUsageDataDetailsActivity activity = (AppUsageDataDetailsActivity) getActivity();
    this.appPackageName = activity.getAppPackageName();
    this.appID = activity.getAppID();

    this.adapter = new DataEntryListAdapter(getActivity(), this.appPackageName);
    elv.setAdapter(this.adapter);

    elv.setGroupIndicator(null);

    getLoaderManager().initLoader(this.loaderID, null, this);
}

From source file:org.mifos.androidclient.main.CollectionSheetActivity.java

protected void updateContent(CollectionSheetData collectionSheet) {
    if (collectionSheet != null) {
        mCollectionSheetData = collectionSheet;

        TextView textView = (TextView) findViewById(R.id.collectionSheet_centerInfo);
        textView.setText("  + " + mCenter.getDisplayName());
        textView.setOnTouchListener(this);

        if (CollectionSheetHolder.getCollectionSheetData() == null) {
            mCollectionSheetData = collectionSheet;
        } else {//from   ww w  . java  2 s  .  com
            mCollectionSheetData = CollectionSheetHolder.getCollectionSheetData();
        }

        mSelectedCustomer = CollectionSheetHolder.getCurrentCustomer();
        if (mSelectedCustomer != null) {
            updateCustomers(collectionSheet);
        }

        if (collectionSheet.getCollectionSheetCustomer() != null
                && collectionSheet.getCollectionSheetCustomer().size() > 0) {

            ExpandableListView expandableListView = (ExpandableListView) findViewById(
                    R.id.collectionSheet_entries);
            CollectionSheetExpandableListAdapter adapter = new CollectionSheetExpandableListAdapter(
                    mCollectionSheetData, this);
            expandableListView.setAdapter(adapter);
            expandableListView.setOnItemLongClickListener(this);
            expandableListView.setOnChildClickListener(this);
            ArrayList<SaveCollectionSheetCustomer> saveCollectionSheetCustomers = new ArrayList<SaveCollectionSheetCustomer>();
            prepareSaveCollectionSheet(saveCollectionSheetCustomers);
            CollectionSheetHolder.getSaveCollectionSheet();
            mSaveCustomer.setSaveCollectionSheetCustomers(saveCollectionSheetCustomers);
            CollectionSheetHolder.setSaveCollectionSheet(mSaveCustomer);
            CollectionSheetHolder.setCollectionSheetData(mCollectionSheetData);
        }
    }

}

From source file:ivl.android.moneybalance.ExpenseListActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    supportRequestWindowFeature(WindowCompat.FEATURE_ACTION_BAR);

    setContentView(R.layout.expense_list);

    Intent intent = getIntent();//  w  w  w  . ja v  a 2s.  c o  m
    calculationId = intent.getLongExtra(PARAM_CALCULATION_ID, -1);

    ExpandableListView listView = (ExpandableListView) findViewById(R.id.expense_list);
    adapter = new ExpenseAdapter(this);
    listView.setAdapter(adapter);
    listView.setOnChildClickListener(this);
    registerForContextMenu(listView);
    setContentView(listView);

    refresh();
}