Example usage for android.widget SimpleExpandableListAdapter SimpleExpandableListAdapter

List of usage examples for android.widget SimpleExpandableListAdapter SimpleExpandableListAdapter

Introduction

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

Prototype

public SimpleExpandableListAdapter(Context context, List<? extends Map<String, ?>> groupData, int groupLayout,
        String[] groupFrom, int[] groupTo, List<? extends List<? extends Map<String, ?>>> childData,
        int childLayout, String[] childFrom, int[] childTo) 

Source Link

Document

Constructor

Usage

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

private void setStopsForRoute(StopsForRouteInfo result) {
    mStopsForRoute = result;/*  w ww. j av  a2s  .  c  o  m*/
    final int code = mStopsForRoute.getResultCode();
    if (code == ObaApi.OBA_OK) {
        setEmptyText("");
    } else {
        setEmptyText(getString(UIHelp.getRouteErrorString(getActivity(), code)));
    }
    mAdapter = new SimpleExpandableListAdapter(getActivity(), result.getStopGroups(),
            android.R.layout.simple_expandable_list_item_1, new String[] { "name" },
            new int[] { android.R.id.text1 }, result.getStops(), R.layout.route_info_listitem,
            new String[] { "name", "direction", "id" }, new int[] { R.id.name, R.id.direction, R.id.stop_id });
    setListAdapter(mAdapter);
}

From source file:com.muggins.test.ble.DeviceControlActivity.java

private void displayGattServices(List<BluetoothGattService> gattServices) {
    if (gattServices == null)
        return;/*  www . j  av a2 s .co  m*/
    String uuid = null;
    //        String unknownServiceString = getResources().getString(R.string.unknown_service);
    //        String unknownCharaString = getResources().getString(R.string.unknown_characteristic);
    ArrayList<HashMap<String, String>> gattServiceData = new ArrayList<HashMap<String, String>>();
    ArrayList<ArrayList<HashMap<String, String>>> gattCharacteristicData = new ArrayList<ArrayList<HashMap<String, String>>>();
    mGattCharacteristics = new ArrayList<ArrayList<BluetoothGattCharacteristic>>();

    // Loops through available GATT Services.
    for (BluetoothGattService gattService : gattServices) {
        HashMap<String, String> currentServiceData = new HashMap<String, String>();
        if (SampleGattAttributes.SERVICE_NUMBER.equals(gattService.getUuid().toString())) {
            uuid = gattService.getUuid().toString();

            //                currentServiceData.put(LIST_NAME, "?");
            //                currentServiceData.put(LIST_UUID, "??1234");
            //                gattServiceData.add(currentServiceData);

            ArrayList<HashMap<String, String>> gattCharacteristicGroupData = new ArrayList<HashMap<String, String>>();
            List<BluetoothGattCharacteristic> gattCharacteristics = gattService.getCharacteristics();
            ArrayList<BluetoothGattCharacteristic> charas = new ArrayList<BluetoothGattCharacteristic>();

            // Loops through available Characteristics.
            for (BluetoothGattCharacteristic gattCharacteristic : gattCharacteristics) {
                charas.add(gattCharacteristic);
                HashMap<String, String> currentCharaData = new HashMap<String, String>();
                if (SampleGattAttributes.HEART_RATE_MEASUREMENT
                        .equals(gattCharacteristic.getUuid().toString())) {
                    uuid = gattCharacteristic.getUuid().toString();

                    currentCharaData.put(LIST_NAME, "?");
                    currentCharaData.put(LIST_UUID, "");
                    gattCharacteristicGroupData.add(currentCharaData);

                    final int charaProp = gattCharacteristic.getProperties();
                    if ((charaProp | BluetoothGattCharacteristic.PROPERTY_READ) > 0) {
                        // If there is an active notification on a characteristic, clear
                        // it first so it doesn't update the data field on the user interface.
                        Log.e("BluetoothLeService", "read");
                        if (mNotifyCharacteristic != null) {
                            mBluetoothLeService.setCharacteristicNotification(
                                    //                                        mNotifyCharacteristic, false);
                                    mNotifyCharacteristic, true);
                            mNotifyCharacteristic = null;
                        }
                        mBluetoothLeService.readCharacteristic(gattCharacteristic);
                        //                            Intent intent = new Intent(DeviceControlActivity.this, ShowWave.class);
                        //                            startActivity(intent);
                    }
                    if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) {
                        Log.e("BluetoothLeService", "notify");
                        mNotifyCharacteristic = gattCharacteristic;
                        mBluetoothLeService.setCharacteristicNotification(gattCharacteristic, true);
                    }

                }
            }
            mGattCharacteristics.add(charas);
            gattCharacteristicData.add(gattCharacteristicGroupData);
        }
    }

    SimpleExpandableListAdapter gattServiceAdapter = new SimpleExpandableListAdapter(this, gattServiceData,
            android.R.layout.simple_expandable_list_item_2, new String[] { LIST_NAME, LIST_UUID },
            new int[] { android.R.id.text1, android.R.id.text2 }, gattCharacteristicData,
            android.R.layout.simple_expandable_list_item_2, new String[] { LIST_NAME, LIST_UUID },
            new int[] { android.R.id.text1, android.R.id.text2 });
    mGattServicesList.setAdapter(gattServiceAdapter);
}

From source file:org.onebusaway.android.ui.RouteInfoListFragment.java

private void setStopsForRoute(StopsForRouteInfo result) {
    mStopsForRoute = result;//from ww  w  .  java 2s . co m
    final int code = mStopsForRoute.getResultCode();
    if (code == ObaApi.OBA_OK) {
        setEmptyText("");
    } else {
        setEmptyText(UIUtils.getRouteErrorString(getActivity(), code));
    }
    mAdapter = new SimpleExpandableListAdapter(getActivity(), result.getStopGroups(),
            android.R.layout.simple_expandable_list_item_1, new String[] { "name" },
            new int[] { android.R.id.text1 }, result.getStops(), R.layout.route_info_listitem,
            new String[] { "name", "direction", "id" }, new int[] { R.id.name, R.id.direction, R.id.stop_id });
    setListAdapter(mAdapter);
}

From source file:com.example.igorklimov.popularmoviesdemo.fragments.DetailFragment.java

private void setupReviews() {
    List<Map<String, String>> groupData = new ArrayList<Map<String, String>>() {
        {/*from  www .  j a  va 2s . com*/
            add(new HashMap<String, String>() {
                {
                    put("ROOT_NAME", "Reviews");
                }
            });
        }
    };
    List<List<Map<String, String>>> listOfChildGroups = new ArrayList<>();

    reviewsList = new ArrayList<>();
    listOfChildGroups.add(reviewsList);

    mReviews.setAdapter(new SimpleExpandableListAdapter(context, groupData, group, new String[] { "ROOT_NAME" },
            new int[] { group_title },

            listOfChildGroups, child, new String[] { AUTHOR, REVIEW_TEXT }, new int[] { author, review_text }));

    final int heightPixels = context.getResources().getDisplayMetrics().heightPixels;
    mReviews.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
        @Override
        public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
            setListViewHeight(parent, groupPosition);
            if (parent.getLayoutParams().height > mDefaultHeight) {
                final int x = mScroll.getScrollX();
                final int y = mScroll.getScrollY() + heightPixels / 4;
                mScroll.post(new Runnable() {
                    @Override
                    public void run() {
                        mScroll.smoothScrollTo(x, y);
                    }
                });
            }
            return false;
        }
    });
}