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: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);/*from  w w  w  . j a  va2 s.co  m*/
    listView.setOnChildClickListener(this);
    listView.setTextFilterEnabled(true);

    return listView;
}

From source file:nl.atcomputing.refcard.fragments.RegExpFragment.java

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    ExpandableListView lv = (ExpandableListView) getView().findViewById(R.id.listview);

    // obtain the basic and extended regexp_array
    regexpb = getResources().getStringArray(R.array.regexpb_array);
    regexpe = getResources().getStringArray(R.array.regexpe_array);
    regexpp = getResources().getStringArray(R.array.regexpp_array);

    // define and activate the expandable list adapter
    SimpleExpandableListAdapter expListAdapter = new SimpleExpandableListAdapter(getActivity(),
            createGroupList(), R.layout.regroups, new String[] { "reCategory" }, new int[] { R.id.recategory },
            createChildList(), R.layout.rerow, new String[] { "resym", "redesc" },
            new int[] { R.id.resymbol, R.id.retext });

    lv.setAdapter(expListAdapter);//from   w w w .  j a  v  a 2 s  .c o  m
}

From source file:nl.atcomputing.refcard.fragments.ViFragment.java

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    ExpandableListView lv = (ExpandableListView) getView().findViewById(R.id.listview);

    // obtain the arrays with the subcommands per category
    visubcmdm = getResources().getStringArray(R.array.visubcomm_array);
    visubcmdi = getResources().getStringArray(R.array.visubcomi_array);
    visubcmde = getResources().getStringArray(R.array.visubcome_array);
    visubcmdf = getResources().getStringArray(R.array.visubcomf_array);

    // define and activate the expandable list adapter
    SimpleExpandableListAdapter expListAdapter = new SimpleExpandableListAdapter(getActivity(),
            createGroupList(), R.layout.vigroups, new String[] { "viCategory" }, new int[] { R.id.vicategory },
            createChildList(), R.layout.virow, new String[] { "viSubCom", "viSubText" },
            new int[] { R.id.visubcom, R.id.visubtext });

    lv.setAdapter(expListAdapter);/*w  ww  .  j  av  a2 s.  co  m*/
}

From source file:org.navitproject.navit.NavitDownloadSelectMapActivity.java

private SimpleExpandableListAdapter createAdapter() {

    NavitMapDownloader.osm_map_values[] osm_maps = NavitMapDownloader.osm_maps;

    ArrayList<HashMap<String, String>> resultGroups = new ArrayList<HashMap<String, String>>();
    ArrayList<ArrayList<HashMap<String, String>>> resultChilds = new ArrayList<ArrayList<HashMap<String, String>>>();

    // add already downloaded maps (group and empty child list
    HashMap<String, String> downloaded_maps_hash = new HashMap<String, String>();
    downloaded_maps_hash.put("category_name", Navit.getInstance().getTstring(R.string.maps_installed));
    resultGroups.add(downloaded_maps_hash);
    downloaded_maps_childs = new ArrayList<HashMap<String, String>>();
    resultChilds.add(downloaded_maps_childs);

    ArrayList<HashMap<String, String>> secList = new ArrayList<HashMap<String, String>>();
    maps_current_position_childs = new ArrayList<HashMap<String, String>>();
    // maps containing the current location
    HashMap<String, String> matching_maps = new HashMap<String, String>();
    matching_maps.put("category_name", Navit.getInstance().getTstring(R.string.maps_for_current_location));
    resultGroups.add(matching_maps);//w w  w . j a va 2 s .  co  m
    resultChilds.add(maps_current_position_childs);

    // add all maps
    for (int currentMapIndex = 0; currentMapIndex < osm_maps.length; currentMapIndex++) {
        if (osm_maps[currentMapIndex].level == 0) {
            if (secList.size() > 0) {
                resultChilds.add(secList);
            }
            secList = new ArrayList<HashMap<String, String>>();
            HashMap<String, String> map_info_hash = new HashMap<String, String>();
            map_info_hash.put("category_name", osm_maps[currentMapIndex].map_name);
            resultGroups.add(map_info_hash);
        }

        HashMap<String, String> child = new HashMap<String, String>();
        child.put("map_name",
                (osm_maps[currentMapIndex].level > 1 ? MAP_BULLETPOINT : "")
                        + osm_maps[currentMapIndex].map_name + " "
                        + (osm_maps[currentMapIndex].est_size_bytes / 1024 / 1024) + "MB");
        child.put("map_index", String.valueOf(currentMapIndex));

        secList.add(child);
    }
    resultChilds.add(secList);

    return new SimpleExpandableListAdapter(this, resultGroups, android.R.layout.simple_expandable_list_item_1,
            new String[] { "category_name" }, new int[] { android.R.id.text1 }, resultChilds,
            android.R.layout.simple_expandable_list_item_1, new String[] { "map_name" },
            new int[] { android.R.id.text1 });
}

From source file:com.darizotas.metadatastrip.FileDetailFragment.java

/** 
 * Updates the view with the metadata contained in the selected file that this fragment
 * is presenting.//  w  ww. j av  a 2  s  .c o  m
 * @param view View
 */
private void updateFileDetails(View view) {
    GroupContainer container = mFileMetadata.getMetadata();

    SimpleExpandableListAdapter adapter = new SimpleExpandableListAdapter(getActivity(),
            // List of groups
            container.getGroups(), R.layout.fragment_detail_rowgroup,
            new String[] { GroupContainer.KEY_GROUP_TEXT }, new int[] { R.id.group_name },
            // List of metadata, per group.
            container.getAllMetadata(), R.layout.fragment_detail_rowtag,
            new String[] { GroupContainer.KEY_TAG_NAME, GroupContainer.KEY_TAG_VALUE },
            new int[] { R.id.tag_name, R.id.tag_value });

    ExpandableListView details = (ExpandableListView) view.findViewById(R.id.detail_list);
    details.setAdapter(adapter);
}

From source file:org.mixare.MixListView.java

public void loadStopDetailsDialog(String title, StopMarker stop) {
    Dialog d = new Dialog(this) {
        public boolean onKeyDown(int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_BACK)
                this.dismiss();
            return true;
        }/*from  w  w w .  j av  a2  s . c  om*/
    };

    d.requestWindowFeature(Window.FEATURE_NO_TITLE);
    d.getWindow().setGravity(Gravity.CENTER);
    d.setContentView(R.layout.stopdetailsdialog);

    TextView titleView = (TextView) d.findViewById(R.id.stopDetailDialogTitle);
    titleView.setText(title);

    ExpandableListView list = (ExpandableListView) d.findViewById(R.id.stopDetailDialogRouteList);

    final Button button = (Button) d.findViewById(R.id.stopWalkRouteButton);
    final double longitude = stop.getLongitude();
    final double latitude = stop.getLatitude();

    final Location start = mixContext.getCurrentLocation();

    button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Intent mapIntent = new Intent(org.mixare.maps.HelloGoogleMapsActivity.class.getName());
            mapIntent.putExtra("startLocation", start);
            mapIntent.putExtra("destLat", latitude);
            mapIntent.putExtra("destLong", longitude);

            startActivity(mapIntent);
        }
    });

    List<Map<String, ?>> groupMaps = stop.getRouteList();
    List<List<Map<String, ?>>> childMaps = stop.getRouteSubdataList();

    SimpleExpandableListAdapter adapter = new SimpleExpandableListAdapter(this, groupMaps,
            R.layout.stopdetailsdialogitemroute, new String[] { "id", "name" },
            new int[] { R.id.routeNumber, R.id.routeName }, childMaps, R.layout.stopdetailsdialogroutevariation,
            new String[] { "direction", "name", "times" },
            new int[] { R.id.routeVariationDirection, R.id.routeVariationName, R.id.routeVariationTimes });

    list.setAdapter(adapter);

    d.show();

    new StopTimesTask(adapter, stop).execute(groupMaps, childMaps);
}

From source file:de.spiritcroc.syncsettings.SelectSyncActivity.java

private void loadSyncs(boolean skipPermissionCheck) {
    // Permission to read accounts required
    if (!skipPermissionCheck && ContextCompat.checkSelfPermission(this,
            Manifest.permission.GET_ACCOUNTS) != PackageManager.PERMISSION_GRANTED) {
        ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.GET_ACCOUNTS },
                REQUEST_PERMISSION_GET_ACCOUNTS);
        return;/*from w  w w.  jav a2  s.co  m*/
    }

    syncs.clear();

    // Syncs with no account will be master sync setting
    syncs.add(new Sync(null, getString(R.string.sync_master_on)));
    syncs.add(new Sync(null, getString(R.string.sync_master_off)));
    syncs.add(new Sync(null, getString(R.string.sync_master_toggle)));

    // Get user accounts
    AccountManager accountManager = AccountManager.get(getApplicationContext());
    Account[] accounts = accountManager.getAccounts();

    // Get authorities
    ArrayList<String> authorities = Util.getAuthorities();

    // Get available account/authority combinations
    if (DEBUG)
        Log.d(LOG_TAG, "Found accounts: " + accounts.length);
    for (Account account : accounts) {
        if (DEBUG)
            Log.d(LOG_TAG, "Found account " + account.name);
        for (int i = 0; i < authorities.size(); i++) {
            if (ContentResolver.getIsSyncable(account, authorities.get(i)) > 0) {
                syncs.add(new Sync(account, authorities.get(i)));
                if (DEBUG)
                    Log.d(LOG_TAG, "Added authority " + authorities.get(i));
            }
        }
    }

    // Build expandable list
    groups.clear();
    for (int i = 0; i < syncs.size(); i++) {
        if (syncs.get(i).account != null && !groups.contains(syncs.get(i).account)) {
            groups.add(syncs.get(i).account);
        }
    }

    final String ROOT = "ROOT_NAME";
    final String CHILD = "CHILD_NAME";

    List<Map<String, String>> groupData = new ArrayList<Map<String, String>>() {
        {
            // Add master sync group:
            add(new HashMap<String, String>() {
                {
                    put(ROOT, getString(R.string.sync_master));
                }
            });
            // Add accounts:
            for (int i = 0; i < groups.size(); i++) {
                final int j = i;
                add(new HashMap<String, String>() {
                    {
                        put(ROOT, groups.get(j).name + " (" + groups.get(j).type + ")");
                    }
                });
            }
        }
    };

    final List<List<Map<String, String>>> listOfChildGroups = new ArrayList<>();

    // Add master sync items:
    List<Map<String, String>> masterChildGroup = new ArrayList<Map<String, String>>() {
        {
            for (int j = 0; j < syncs.size(); j++) {
                final Sync sync = syncs.get(j);
                if (sync.account == null) {
                    add(new HashMap<String, String>() {
                        {
                            put(CHILD, sync.authority);
                        }
                    });
                } else {
                    break;
                }
            }
        }
    };
    // Add account data:
    listOfChildGroups.add(masterChildGroup);
    for (int i = 0; i < groups.size(); i++) {
        final int x = i;
        List<Map<String, String>> childGroup = new ArrayList<Map<String, String>>() {
            {
                for (int j = 0; j < syncs.size(); j++) {
                    final Sync sync = syncs.get(j);
                    if (sync.account != null && sync.account.equals(groups.get(x))) {
                        add(new HashMap<String, String>() {
                            {
                                put(CHILD, sync.authority);
                            }
                        });
                    }
                }
            }
        };
        listOfChildGroups.add(childGroup);
    }

    listView.setAdapter(new SimpleExpandableListAdapter(this,

            groupData, android.R.layout.simple_expandable_list_item_1, new String[] { ROOT },
            new int[] { android.R.id.text1 },

            listOfChildGroups, android.R.layout.simple_expandable_list_item_1, new String[] { CHILD },
            new int[] { android.R.id.text1 }));
}

From source file:org.zpcat.ble.ui.central.DeviceControlActivity.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
private void displayGattServices(List<BluetoothGattService> gattServices) {
    Log.d("displayGATTServices");

    if (gattServices == null)
        return;//from  w  w  w  . j a  va 2  s  .com
    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>();
        uuid = gattService.getUuid().toString();
        currentServiceData.put(LIST_NAME, SampleGattAttributes.lookup(uuid, unknownServiceString));
        currentServiceData.put(LIST_UUID, uuid);
        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>();
            uuid = gattCharacteristic.getUuid().toString();
            currentCharaData.put(LIST_NAME, SampleGattAttributes.lookup(uuid, unknownCharaString));
            currentCharaData.put(LIST_UUID, uuid);
            gattCharacteristicGroupData.add(currentCharaData);
        }
        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:com.touchKin.touchkinapp.DeviceControlActivity.java

private void displayGattServices(List<BluetoothGattService> gattServices) {
    if (gattServices == null)
        return;/*  www .  ja  v a 2  s.  c  o  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>();
        uuid = gattService.getUuid().toString();
        currentServiceData.put(LIST_NAME, SampleGattAttributes.lookup(uuid, unknownServiceString));
        currentServiceData.put(LIST_UUID, uuid);
        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.
        characteristicTX = gattService
                .getCharacteristic(UUID.fromString("00001525-1212-efde-1523-785feabcd123"));
        characteristicRX = gattService
                .getCharacteristic(UUID.fromString("00001525-1212-efde-1523-785feabcd123"));
        for (BluetoothGattCharacteristic gattCharacteristic : gattCharacteristics) {
            charas.add(gattCharacteristic);
            HashMap<String, String> currentCharaData = new HashMap<String, String>();
            uuid = gattCharacteristic.getUuid().toString();
            currentCharaData.put(LIST_NAME, SampleGattAttributes.lookup(uuid, unknownCharaString));
            currentCharaData.put(LIST_UUID, uuid);
            gattCharacteristicGroupData.add(currentCharaData);
        }
        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:com.example.bluetoothlegatt.DeviceControlActivity.java

private void displayGattServices(List<BluetoothGattService> gattServices) {
    if (gattServices == null)
        return;/*w w w  .  j  a  v  a 2 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>();
        uuid = gattService.getUuid().toString();
        currentServiceData.put(LIST_NAME, SampleGattAttributes.lookup(uuid, unknownServiceString));
        currentServiceData.put(LIST_UUID, uuid);
        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>();
            uuid = gattCharacteristic.getUuid().toString();
            currentCharaData.put(LIST_NAME, SampleGattAttributes.lookup(uuid, unknownCharaString));
            currentCharaData.put(LIST_UUID, uuid);
            gattCharacteristicGroupData.add(currentCharaData);
        }
        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);
}