Java 类android.widget.SimpleExpandableListAdapter 实例源码

项目:BLEFOTA    文件:BflFwUploader.java   
/**
 * Update GATT service adapter.
 *
 * @param gattServiceData is services list.
 * @param gattCharacteristicData is characteristics list.
 * @return GATT service adapter.
 * @see kr.co.sevencore.blefotalib.BflFwUploadService
 */
public SimpleExpandableListAdapter updateGattServicesAdapter(
        ArrayList<HashMap<String, String>> gattServiceData, ArrayList<ArrayList<HashMap<String, String>>> gattCharacteristicData) {
    SimpleExpandableListAdapter gattServiceAdapter = new SimpleExpandableListAdapter(
            mContext,
            gattServiceData,
            android.R.layout.simple_expandable_list_item_2,
            new String[] {BflCodeList.LIST_NAME, BflCodeList.LIST_UUID},
            new int[] { android.R.id.text1, android.R.id.text2},
            gattCharacteristicData,
            android.R.layout.simple_expandable_list_item_2,
            new String[] {BflCodeList.LIST_NAME, BflCodeList.LIST_UUID},
            new int[] { android.R.id.text1, android.R.id.text2 }
    );
    return gattServiceAdapter;
}
项目:SaldoTicket    文件:TransactionsActivity.java   
@Override
protected Void doInBackground(Void... arg0) {
    expListAdapter =
            new SimpleExpandableListAdapter(
                    TransactionsActivity.this,
                    createGroupList(),              // Creating group List.
                    R.layout.group_row,             // Group item layout XML.
                    new String[] { "Month" },  // the key of group item.
                    new int[] { R.id.row_name },    // ID of each group item.-Data under the key goes into this TextView.
                    createChildList(),              // childData describes second-level entries.
                    R.layout.child_row,             // Layout for sub-level entries(second level).
                    new String[] {"Transaction"},      // Keys in childData maps to display.
                    new int[] { R.id.grp_child}     // Data under the keys above go into these TextViews.
            );
    return null;
}
项目:SaldoTicket    文件:TransactionsShortActivity.java   
@Override
protected Void doInBackground(Void... arg0) {
    expListAdapter =
            new SimpleExpandableListAdapter(
                    TransactionsShortActivity.this,
                    createGroupList(),              // Creating group List.
                    R.layout.group_row,             // Group item layout XML.
                    new String[] { "Month" },  // the key of group item.
                    new int[] { R.id.row_name },    // ID of each group item.-Data under the key goes into this TextView.
                    createChildList(),              // childData describes second-level entries.
                    R.layout.child_row,             // Layout for sub-level entries(second level).
                    new String[] {"Transaction"},      // Keys in childData maps to display.
                    new int[] { R.id.grp_child}     // Data under the keys above go into these TextViews.
            );
    return null;
}
项目:android-BluetoothLowEnergy    文件:DeviceControlActivity.java   
protected void clearUI() {
    mDeviceAddress.setText(String.format(getString(R.string.ble_address), ""));
    mDeviceStatus.setText(String.format(getString(R.string.ble_state), ""));
    mDeviceData.setText(String.format(getString(R.string.ble_data), ""));

    mDeviceService.setAdapter((SimpleExpandableListAdapter)null);
}
项目:AndroidBleManager    文件:DeviceControlActivity.java   
private void clearUI() {
    mGattServicesList.setAdapter((SimpleExpandableListAdapter) null);
    mGattUUID.setText(R.string.no_data);
    mGattUUIDDesc.setText(R.string.no_data);
    mDataAsArray.setText(R.string.no_data);
    mDataAsString.setText(R.string.no_data);
}
项目:OverPulltorefresh    文件:PullToRefreshExpandableListActivity.java   
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_ptr_expandable_list);

    mPullRefreshListView = (PullToRefreshExpandableListView) findViewById(R.id.pull_refresh_expandable_list);

    // Set a listener to be invoked when the list should be refreshed.
    mPullRefreshListView.setOnRefreshListener(new OnRefreshListener<ExpandableListView>() {
        @Override
        public void onRefresh(PullToRefreshBase<ExpandableListView> refreshView) {
            // Do work to refresh the list here.
            new GetDataTask().execute();
        }
    });

    for (String group : mGroupStrings) {
        Map<String, String> groupMap1 = new HashMap<String, String>();
        groupData.add(groupMap1);
        groupMap1.put(KEY, group);

        List<Map<String, String>> childList = new ArrayList<Map<String, String>>();
        for (String string : mChildStrings) {
            Map<String, String> childMap = new HashMap<String, String>();
            childList.add(childMap);
            childMap.put(KEY, string);
        }
        childData.add(childList);
    }

    mAdapter = new SimpleExpandableListAdapter(this, groupData, android.R.layout.simple_expandable_list_item_1,
            new String[] { KEY }, new int[] { android.R.id.text1 }, childData,
            android.R.layout.simple_expandable_list_item_2, new String[] { KEY }, new int[] { android.R.id.text1 });
    setListAdapter(mAdapter);
}
项目:anvil-examples    文件:ExpandableListLayout.java   
public ExpandableListLayout(Context c) {
    super(c);

    expanded = new boolean[GROUP.length];
    List<Map<String, String>> groupData = new ArrayList<>();
    List<List<Map<String, String>>> childData = new ArrayList<>();
    for (int i = 0; i < GROUP.length; i++) {
        Map<String, String> map = new HashMap<String, String>();
        groupData.add(map);
        map.put(NAME, GROUP[i]);

        List<Map<String, String>> children = new ArrayList<>();
        for (int j = 0; j < CHILD[i].length; j++) {
            Map<String, String> childMap = new HashMap<String, String>();
            children.add(childMap);
            childMap.put(NAME, CHILD[i][j]);
        }
        childData.add(children);
        expanded[i] = false;
    }

    mAdapter = new SimpleExpandableListAdapter(c, groupData,
            android.R.layout.simple_expandable_list_item_1,
            new String[] { NAME }, new int[] { android.R.id.text1 },
            childData, android.R.layout.simple_expandable_list_item_2,
            new String[] { NAME }, new int[] { android.R.id.text1 });
}
项目:ApkLauncher    文件:ExpandableList3.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    List<Map<String, String>> groupData = new ArrayList<Map<String, String>>();
    List<List<Map<String, String>>> childData = new ArrayList<List<Map<String, String>>>();
    for (int i = 0; i < 20; i++) {
        Map<String, String> curGroupMap = new HashMap<String, String>();
        groupData.add(curGroupMap);
        curGroupMap.put(NAME, "Group " + i);
        curGroupMap.put(IS_EVEN, (i % 2 == 0) ? "This group is even" : "This group is odd");

        List<Map<String, String>> children = new ArrayList<Map<String, String>>();
        for (int j = 0; j < 15; j++) {
            Map<String, String> curChildMap = new HashMap<String, String>();
            children.add(curChildMap);
            curChildMap.put(NAME, "Child " + j);
            curChildMap.put(IS_EVEN, (j % 2 == 0) ? "This child is even" : "This child is odd");
        }
        childData.add(children);
    }

    // Set up our adapter
    mAdapter = new SimpleExpandableListAdapter(
            this,
            groupData,
            android.R.layout.simple_expandable_list_item_1,
            new String[] { NAME, IS_EVEN },
            new int[] { android.R.id.text1, android.R.id.text2 },
            childData,
            android.R.layout.simple_expandable_list_item_2,
            new String[] { NAME, IS_EVEN },
            new int[] { android.R.id.text1, android.R.id.text2 }
            );
    setListAdapter(mAdapter);
}
项目:ApiDemos    文件:ExpandableList3.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    List<Map<String, String>> groupData = new ArrayList<Map<String, String>>();
    List<List<Map<String, String>>> childData = new ArrayList<List<Map<String, String>>>();
    for (int i = 0; i < 20; i++) {
        Map<String, String> curGroupMap = new HashMap<String, String>();
        groupData.add(curGroupMap);
        curGroupMap.put(NAME, "Group " + i);
        curGroupMap.put(IS_EVEN, (i % 2 == 0) ? "This group is even" : "This group is odd");

        List<Map<String, String>> children = new ArrayList<Map<String, String>>();
        for (int j = 0; j < 15; j++) {
            Map<String, String> curChildMap = new HashMap<String, String>();
            children.add(curChildMap);
            curChildMap.put(NAME, "Child " + j);
            curChildMap.put(IS_EVEN, (j % 2 == 0) ? "This child is even" : "This child is odd");
        }
        childData.add(children);
    }

    // Set up our adapter
    mAdapter = new SimpleExpandableListAdapter(
            this,
            groupData,
            android.R.layout.simple_expandable_list_item_1,
            new String[] { NAME, IS_EVEN },
            new int[] { android.R.id.text1, android.R.id.text2 },
            childData,
            android.R.layout.simple_expandable_list_item_2,
            new String[] { NAME, IS_EVEN },
            new int[] { android.R.id.text1, android.R.id.text2 }
            );
    setListAdapter(mAdapter);
}
项目:FullRobolectricTestSample    文件:ExpandableListViewTest.java   
@Ignore("not yet working in 2.0, sorry :-(") // todo 2.0-cleanup
@Test
public void testPerformItemClick_ShouldFireOnItemClickListener() throws Exception {
  SimpleExpandableListAdapter adapter = holyCrapYouHaveGotToBeKidding();
  expandableListView.setAdapter(adapter);
  expandableListView.setOnChildClickListener(myOnChildClickListener);
  expandableListView.expandGroup(1);
  shadowOf(expandableListView).populateItems();
  expandableListView.performItemClick(null, 0, -1); // open the group...
  expandableListView.performItemClick(null, 6, -1);
  transcript.assertEventsSoFar("item was clicked: 6");
}
项目:FullRobolectricTestSample    文件:ExpandableListViewTest.java   
private SimpleExpandableListAdapter holyCrapYouHaveGotToBeKidding() {
  List<Map<String, String>> groupData = new ArrayList<Map<String, String>>();
  List<List<Map<String, String>>> childData = new ArrayList<List<Map<String, String>>>();
  for (int i = 0; i < 20; i++) {
    Map<String, String> curGroupMap = new HashMap<String, String>();
    groupData.add(curGroupMap);
    curGroupMap.put("NAME", "Item " + i);
    curGroupMap.put("IS_EVEN", (i % 2 == 0) ? "This group is even" : "This group is odd");

    List<Map<String, String>> children = new ArrayList<Map<String, String>>();
    for (int j = 0; j < 5; j++) {
      Map<String, String> curChildMap = new HashMap<String, String>();
      children.add(curChildMap);
      // curChildMap.put(NAME, "Child " + j);
      curChildMap.put("IS_EVEN", (j % 2 == 0) ? "Hello " + j : "Good Morning " + j);
    }
    childData.add(children);
  }

  return new SimpleExpandableListAdapter(
      Robolectric.application,
      groupData,
      R.layout.simple_expandable_list_item_1,
      new String[] {"NAME", "IS_EVEN"},
      new int[] {R.id.text1, R.id.text2},
      childData,
      R.layout.simple_expandable_list_item_2,
      new String[] {"NAME", "IS_EVEN"},
      new int[] {R.id.text1, R.id.text2}
  );
}
项目:Bluetooth-LE-Library---Android    文件:DeviceControlActivity.java   
private void clearUI() {
    mExportString = null;
    mGattServicesList.setAdapter((SimpleExpandableListAdapter) null);
    mGattUUID.setText(R.string.no_data);
    mGattUUIDDesc.setText(R.string.no_data);
    mDataAsArray.setText(R.string.no_data);
    mDataAsString.setText(R.string.no_data);
}
项目:UltimateAndroid    文件:ExpandableListViewActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.edge_effect_expandablelistview_layout);

    //this comes from android samples
    List<Map<String, String>> groupData = new ArrayList<Map<String, String>>();
    List<List<Map<String, String>>> childData = new ArrayList<List<Map<String, String>>>();
    for (int i = 0; i < 20; i++) {
        Map<String, String> curGroupMap = new HashMap<String, String>();
        groupData.add(curGroupMap);
        curGroupMap.put(NAME, "Group " + i);
        curGroupMap.put(IS_EVEN, (i % 2 == 0) ? "This group is even" : "This group is odd");

        List<Map<String, String>> children = new ArrayList<Map<String, String>>();
        for (int j = 0; j < 15; j++) {
            Map<String, String> curChildMap = new HashMap<String, String>();
            children.add(curChildMap);
            curChildMap.put(NAME, "Child " + j);
            curChildMap.put(IS_EVEN, (j % 2 == 0) ? "This child is even" : "This child is odd");
        }
        childData.add(children);
    }

    // Set up our adapter
    ((EdgeEffectExpandableListView) findViewById(R.id.expandablelistview)).setAdapter(new SimpleExpandableListAdapter(
            this,
            groupData,
            android.R.layout.simple_expandable_list_item_1,
            new String[]{NAME, IS_EVEN},
            new int[]{android.R.id.text1, android.R.id.text2},
            childData,
            android.R.layout.simple_expandable_list_item_2,
            new String[]{NAME, IS_EVEN},
            new int[]{android.R.id.text1, android.R.id.text2}
    ));
}
项目:UltimateAndroid    文件:ExpandableListViewActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.edge_effect_expandablelistview_layout);

    //this comes from android samples
    List<Map<String, String>> groupData = new ArrayList<Map<String, String>>();
    List<List<Map<String, String>>> childData = new ArrayList<List<Map<String, String>>>();
    for (int i = 0; i < 20; i++) {
        Map<String, String> curGroupMap = new HashMap<String, String>();
        groupData.add(curGroupMap);
        curGroupMap.put(NAME, "Group " + i);
        curGroupMap.put(IS_EVEN, (i % 2 == 0) ? "This group is even" : "This group is odd");

        List<Map<String, String>> children = new ArrayList<Map<String, String>>();
        for (int j = 0; j < 15; j++) {
            Map<String, String> curChildMap = new HashMap<String, String>();
            children.add(curChildMap);
            curChildMap.put(NAME, "Child " + j);
            curChildMap.put(IS_EVEN, (j % 2 == 0) ? "This child is even" : "This child is odd");
        }
        childData.add(children);
    }

    // Set up our adapter
    ((EdgeEffectExpandableListView) findViewById(R.id.expandablelistview)).setAdapter(new SimpleExpandableListAdapter(
            this,
            groupData,
            android.R.layout.simple_expandable_list_item_1,
            new String[]{NAME, IS_EVEN},
            new int[]{android.R.id.text1, android.R.id.text2},
            childData,
            android.R.layout.simple_expandable_list_item_2,
            new String[]{NAME, IS_EVEN},
            new int[]{android.R.id.text1, android.R.id.text2}
    ));
}
项目:Z_MyProPullToRefresh    文件:PullToRefreshExpandableListActivity.java   
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_ptr_expandable_list);

    mPullRefreshListView = (PullToRefreshExpandableListView) findViewById(R.id.pull_refresh_expandable_list);

    // Set a listener to be invoked when the list should be refreshed.
    mPullRefreshListView.setOnRefreshListener(new OnRefreshListener<ExpandableListView>() {
        @Override
        public void onRefresh(PullToRefreshBase<ExpandableListView> refreshView) {
            // Do work to refresh the list here.
            new GetDataTask().execute();
        }
    });

    for (String group : mGroupStrings) {
        Map<String, String> groupMap1 = new HashMap<String, String>();
        groupData.add(groupMap1);
        groupMap1.put(KEY, group);

        List<Map<String, String>> childList = new ArrayList<Map<String, String>>();
        for (String string : mChildStrings) {
            Map<String, String> childMap = new HashMap<String, String>();
            childList.add(childMap);
            childMap.put(KEY, string);
        }
        childData.add(childList);
    }

    mAdapter = new SimpleExpandableListAdapter(this, groupData, android.R.layout.simple_expandable_list_item_1,
            new String[] { KEY }, new int[] { android.R.id.text1 }, childData,
            android.R.layout.simple_expandable_list_item_2, new String[] { KEY }, new int[] { android.R.id.text1 });
    setListAdapter(mAdapter);
}
项目:irma_future_id    文件:PluginActivity.java   
/**
    * Creates the View containing the Plugin's actions.
    * 
    * @return The View containing the Plugin's actions.
    */
   private ScrollView createActionsView() {
LayoutParams fillParams = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
int padding = this.getResources().getDimensionPixelSize(R.dimen.padding);

ScrollView sv = new ScrollView(PluginActivity.this);
sv.setLayoutParams(fillParams);
sv.setPadding(padding, padding, padding, padding);

ExpandableListView elv = new ExpandableListView(PluginActivity.this) {
    // workaround to get a ExpandableListView displayed in a ScrollView
    @Override
    public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    // Calculate entire height by providing a very large height hint.
    // But do not use the highest 2 bits of this integer; those are
    // reserved for the MeasureSpec mode.
    int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
    super.onMeasure(widthMeasureSpec, expandSpec);

    android.view.ViewGroup.LayoutParams params = getLayoutParams();
    params.height = getMeasuredHeight();
    }
};

elv.setLayoutParams(fillParams);
SimpleExpandableListAdapter sela = new PluginActionsExpandableListAdapter(this, PluginActivity.this,
    createGroupList(), R.layout.group_row, new String[] { NAME }, new int[] { R.id.row_name },
    createChildList(), R.layout.child_row, new String[] { DESC }, new int[] { R.id.grp_child });
elv.setAdapter(sela);
sv.addView(elv);
return sv;
   }
项目:Android-PullToRefresh-VerticalViewPager    文件:PullToRefreshExpandableListActivity.java   
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_ptr_expandable_list);

    mPullRefreshListView = (PullToRefreshExpandableListView) findViewById(R.id.pull_refresh_expandable_list);

    // Set a listener to be invoked when the list should be refreshed.
    mPullRefreshListView.setOnRefreshListener(new OnRefreshListener<ExpandableListView>() {
        @Override
        public void onRefresh(PullToRefreshBase<ExpandableListView> refreshView) {
            // Do work to refresh the list here.
            new GetDataTask().execute();
        }
    });

    for (String group : mGroupStrings) {
        Map<String, String> groupMap1 = new HashMap<String, String>();
        groupData.add(groupMap1);
        groupMap1.put(KEY, group);

        List<Map<String, String>> childList = new ArrayList<Map<String, String>>();
        for (String string : mChildStrings) {
            Map<String, String> childMap = new HashMap<String, String>();
            childList.add(childMap);
            childMap.put(KEY, string);
        }
        childData.add(childList);
    }

    mAdapter = new SimpleExpandableListAdapter(this, groupData, android.R.layout.simple_expandable_list_item_1,
            new String[] { KEY }, new int[] { android.R.id.text1 }, childData,
            android.R.layout.simple_expandable_list_item_2, new String[] { KEY }, new int[] { android.R.id.text1 });
    setListAdapter(mAdapter);
}
项目:felix-on-android    文件:ExpandableList3.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    List<Map<String, String>> groupData = new ArrayList<Map<String, String>>();
    List<List<Map<String, String>>> childData = new ArrayList<List<Map<String, String>>>();
    for (int i = 0; i < 20; i++) {
        Map<String, String> curGroupMap = new HashMap<String, String>();
        groupData.add(curGroupMap);
        curGroupMap.put(NAME, "Group " + i);
        curGroupMap.put(IS_EVEN, (i % 2 == 0) ? "This group is even" : "This group is odd");

        List<Map<String, String>> children = new ArrayList<Map<String, String>>();
        for (int j = 0; j < 15; j++) {
            Map<String, String> curChildMap = new HashMap<String, String>();
            children.add(curChildMap);
            curChildMap.put(NAME, "Child " + j);
            curChildMap.put(IS_EVEN, (j % 2 == 0) ? "This child is even" : "This child is odd");
        }
        childData.add(children);
    }

    // Set up our adapter
    mAdapter = new SimpleExpandableListAdapter(
            this,
            groupData,
            android.R.layout.simple_expandable_list_item_1,
            new String[] { NAME, IS_EVEN },
            new int[] { android.R.id.text1, android.R.id.text2 },
            childData,
            android.R.layout.simple_expandable_list_item_2,
            new String[] { NAME, IS_EVEN },
            new int[] { android.R.id.text1, android.R.id.text2 }
            );
    setListAdapter(mAdapter);
}
项目:MEng    文件:ExpandableList3.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    List<Map<String, String>> groupData = new ArrayList<Map<String, String>>();
    List<List<Map<String, String>>> childData = new ArrayList<List<Map<String, String>>>();
    for (int i = 0; i < 20; i++) {
        Map<String, String> curGroupMap = new HashMap<String, String>();
        groupData.add(curGroupMap);
        curGroupMap.put(NAME, "Group " + i);
        curGroupMap.put(IS_EVEN, (i % 2 == 0) ? "This group is even" : "This group is odd");

        List<Map<String, String>> children = new ArrayList<Map<String, String>>();
        for (int j = 0; j < 15; j++) {
            Map<String, String> curChildMap = new HashMap<String, String>();
            children.add(curChildMap);
            curChildMap.put(NAME, "Child " + j);
            curChildMap.put(IS_EVEN, (j % 2 == 0) ? "This child is even" : "This child is odd");
        }
        childData.add(children);
    }

    // Set up our adapter
    mAdapter = new SimpleExpandableListAdapter(
            this,
            groupData,
            android.R.layout.simple_expandable_list_item_1,
            new String[] { NAME, IS_EVEN },
            new int[] { android.R.id.text1, android.R.id.text2 },
            childData,
            android.R.layout.simple_expandable_list_item_2,
            new String[] { NAME, IS_EVEN },
            new int[] { android.R.id.text1, android.R.id.text2 }
            );
    setListAdapter(mAdapter);
}
项目:RoviRunner    文件:MainActivityPresenter.java   
@Override
public ExpandableListAdapter getStreamingSourcesAdapter()
{
    // refer to:  http://blog.denevell.org/android-SimpleExpandableListAdapter-example.html

    // keys for our maps we'll be creating
    final String KEY_GROUP_NAME = "GROUP_NAME";
    final String KEY_CHILD_NAME = "STREAM_SOURCE";

    // we only have one parent
    List<Map<String, String>> listOfParents = new ArrayList<Map<String, String>>();
    Map<String, String> parents = new HashMap<String, String>();
    parents.put( KEY_GROUP_NAME, "Stream music from..." );
    listOfParents.add( parents );

    // that one parent has children; each child needs to be its own map, which may 
    // seem interesting, but it's required by SimpleExpandableListAdapter
    List<List<Map<String, String>>> listOfChildLists = new ArrayList<List<Map<String, String>>>();
    List<Map<String, String>> children = new ArrayList<Map<String, String>>();
    for ( String value : m_streamingSourcesMgr.getAvailableStreamingSources().values() )
    {
        Map<String, String> child = new HashMap<String, String>();
        child.put( KEY_CHILD_NAME, value );
        children.add( child );
    }
    listOfChildLists.add( children );

    ExpandableListAdapter adapter = new SimpleExpandableListAdapter( m_context,
                                                                     listOfParents,
                                                                     R.layout.streaming_sources_group_view,
                                                                     new String[] { KEY_GROUP_NAME },
                                                                     new int[] { R.id.streaming_sources_group_name },
                                                                     listOfChildLists,
                                                                     R.layout.streaming_sources_row_view,
                                                                     new String[] { KEY_CHILD_NAME },
                                                                     new int[] { R.id.streaming_sources_row_name } );

    return adapter;
}
项目:codeexamples-android    文件:ExpandableList3.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    List<Map<String, String>> groupData = new ArrayList<Map<String, String>>();
    List<List<Map<String, String>>> childData = new ArrayList<List<Map<String, String>>>();
    for (int i = 0; i < 20; i++) {
        Map<String, String> curGroupMap = new HashMap<String, String>();
        groupData.add(curGroupMap);
        curGroupMap.put(NAME, "Group " + i);
        curGroupMap.put(IS_EVEN, (i % 2 == 0) ? "This group is even" : "This group is odd");

        List<Map<String, String>> children = new ArrayList<Map<String, String>>();
        for (int j = 0; j < 15; j++) {
            Map<String, String> curChildMap = new HashMap<String, String>();
            children.add(curChildMap);
            curChildMap.put(NAME, "Child " + j);
            curChildMap.put(IS_EVEN, (j % 2 == 0) ? "This child is even" : "This child is odd");
        }
        childData.add(children);
    }

    // Set up our adapter
    mAdapter = new SimpleExpandableListAdapter(
            this,
            groupData,
            android.R.layout.simple_expandable_list_item_1,
            new String[] { NAME, IS_EVEN },
            new int[] { android.R.id.text1, android.R.id.text2 },
            childData,
            android.R.layout.simple_expandable_list_item_2,
            new String[] { NAME, IS_EVEN },
            new int[] { android.R.id.text1, android.R.id.text2 }
            );
    setListAdapter(mAdapter);
}
项目:deview-2013-samples    文件:ExpandableList3.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    List<Map<String, String>> groupData = new ArrayList<Map<String, String>>();
    List<List<Map<String, String>>> childData = new ArrayList<List<Map<String, String>>>();
    for (int i = 0; i < 20; i++) {
        Map<String, String> curGroupMap = new HashMap<String, String>();
        groupData.add(curGroupMap);
        curGroupMap.put(NAME, "Group " + i);
        curGroupMap.put(IS_EVEN, (i % 2 == 0) ? "This group is even" : "This group is odd");

        List<Map<String, String>> children = new ArrayList<Map<String, String>>();
        for (int j = 0; j < 15; j++) {
            Map<String, String> curChildMap = new HashMap<String, String>();
            children.add(curChildMap);
            curChildMap.put(NAME, "Child " + j);
            curChildMap.put(IS_EVEN, (j % 2 == 0) ? "This child is even" : "This child is odd");
        }
        childData.add(children);
    }

    // Set up our adapter
    mAdapter = new SimpleExpandableListAdapter(
            this,
            groupData,
            android.R.layout.simple_expandable_list_item_1,
            new String[] { NAME, IS_EVEN },
            new int[] { android.R.id.text1, android.R.id.text2 },
            childData,
            android.R.layout.simple_expandable_list_item_2,
            new String[] { NAME, IS_EVEN },
            new int[] { android.R.id.text1, android.R.id.text2 }
            );
    setListAdapter(mAdapter);
}
项目:PullToRefresh-StaggeredGridView    文件:PullToRefreshExpandableListActivity.java   
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_ptr_expandable_list);

    mPullRefreshListView = (PullToRefreshExpandableListView) findViewById(R.id.pull_refresh_expandable_list);

    // Set a listener to be invoked when the list should be refreshed.
    mPullRefreshListView.setOnRefreshListener(new OnRefreshListener<ExpandableListView>() {
        @Override
        public void onRefresh(PullToRefreshBase<ExpandableListView> refreshView) {
            // Do work to refresh the list here.
            new GetDataTask().execute();
        }
    });

    for (String group : mGroupStrings) {
        Map<String, String> groupMap1 = new HashMap<String, String>();
        groupData.add(groupMap1);
        groupMap1.put(KEY, group);

        List<Map<String, String>> childList = new ArrayList<Map<String, String>>();
        for (String string : mChildStrings) {
            Map<String, String> childMap = new HashMap<String, String>();
            childList.add(childMap);
            childMap.put(KEY, string);
        }
        childData.add(childList);
    }

    mAdapter = new SimpleExpandableListAdapter(this, groupData, android.R.layout.simple_expandable_list_item_1,
            new String[] { KEY }, new int[] { android.R.id.text1 }, childData,
            android.R.layout.simple_expandable_list_item_2, new String[] { KEY }, new int[] { android.R.id.text1 });
    setListAdapter(mAdapter);
}
项目:igrow-android    文件:DeviceControlActivity.java   
private void clearUI() {
    mGattServicesList.setAdapter((SimpleExpandableListAdapter) null);
    mDataField.setText(com.igrow.android.R.string.no_data);
}
项目:igrow-android    文件:DeviceControlActivity.java   
private void displayGattServices(List<BluetoothGattService> gattServices) {
    if (gattServices == null) return;
    String uuid = null;
    String unknownServiceString = getResources().getString(com.igrow.android.R.string.unknown_service);
    String unknownCharaString = getResources().getString(com.igrow.android.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, IGrowGattAttributes.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, IGrowGattAttributes.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);
}
项目:Android-BLE-to-Arduino    文件:DeviceControlActivity.java   
private void clearUI() {
    mGattServicesList.setAdapter((SimpleExpandableListAdapter) null);
    mDataField.setText(R.string.no_data);
}
项目:Android-BLE-to-Arduino    文件:DeviceControlActivity.java   
private void displayGattServices(List<BluetoothGattService> gattServices) {
    if (gattServices == null)
        return;
    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);

}
项目:BLE    文件:DeviceControlActivity.java   
/**
 * 根据GATT服务显示该服务下的所有特征值
 *
 * @param gattServices GATT服务
 * @return
 */
private SimpleExpandableListAdapter displayGattServices(final List<BluetoothGattService> gattServices) {
    if (gattServices == null) return null;
    String uuid;
    final String unknownServiceString = getResources().getString(R.string.unknown_service);
    final String unknownCharaString = getResources().getString(R.string.unknown_characteristic);
    final List<Map<String, String>> gattServiceData = new ArrayList<>();
    final List<List<Map<String, String>>> gattCharacteristicData = new ArrayList<>();

    mGattServices = new ArrayList<>();
    mGattCharacteristics = new ArrayList<>();

    // Loops through available GATT Services.
    for (final BluetoothGattService gattService : gattServices) {
        final Map<String, String> currentServiceData = new HashMap<>();
        uuid = gattService.getUuid().toString();
        currentServiceData.put(LIST_NAME, GattAttributeResolver.getAttributeName(uuid, unknownServiceString));
        currentServiceData.put(LIST_UUID, uuid);
        gattServiceData.add(currentServiceData);

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

        // Loops through available Characteristics.
        for (final BluetoothGattCharacteristic gattCharacteristic : gattCharacteristics) {
            charas.add(gattCharacteristic);
            final Map<String, String> currentCharaData = new HashMap<>();
            uuid = gattCharacteristic.getUuid().toString();
            currentCharaData.put(LIST_NAME, GattAttributeResolver.getAttributeName(uuid, unknownCharaString));
            currentCharaData.put(LIST_UUID, uuid);
            gattCharacteristicGroupData.add(currentCharaData);
        }

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

    final 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});
    return gattServiceAdapter;
}
项目:sample-android-ble    文件:DeviceControlActivity.java   
private void clearUI() {
    mGattServicesList.setAdapter((SimpleExpandableListAdapter) null);
    mDataField.setText(R.string.no_data);
}
项目:sample-android-ble    文件:DeviceControlActivity.java   
private void displayGattServices(List<BluetoothGattService> gattServices) {
    if (gattServices == null) return;
    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);
}
项目:android-BluetoothLowEnergy    文件:DeviceControlActivity.java   
/**
 * 显示Gatt服务
 *
 * @param gattServices
 */
protected void displayGattService(List<BluetoothGattService> gattServices) {
    if (gattServices == null) {
        return;
    }

    ArrayList<HashMap<String, String>> gattServiceData = new ArrayList<>();
    ArrayList<List<HashMap<String, String>>> gattCharacteristicData = new ArrayList<>();

    mGattCharacteristics = new ArrayList<>();

    String LIST_PROPERTY = "PROPERTIES";
    String LIST_UUID = "UUID";

    for (BluetoothGattService gattService : gattServices) {
        final HashMap<String, String> currentServiceData = new HashMap<>();
        String serviceUuid = gattService.getUuid().toString();
        currentServiceData.put(LIST_UUID, serviceUuid);

        gattServiceData.add(currentServiceData);

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

        for (BluetoothGattCharacteristic gattCharacteristic : gattCharacteristics) {
            chars.add(gattCharacteristic);
            final HashMap<String, String> currentCharaData = new HashMap<>();
            String characteristicUuid = gattCharacteristic.getUuid().toString();
            String property = gattCharacteristicPropertySwitch(gattCharacteristic);
            currentCharaData.put(LIST_PROPERTY, getString(R.string.ble_property) + property);
            currentCharaData.put(LIST_UUID, characteristicUuid);
            gattCharacteristicGroupData.add(currentCharaData);
        }
        mGattCharacteristics.add(chars);
        gattCharacteristicData.add(gattCharacteristicGroupData);

    }

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

    };
    mDeviceService.setAdapter(gattServiceAdapter);
}
项目:AndroidBleManager    文件:DeviceControlActivity.java   
private void displayGattServices(final List<BluetoothGattService> gattServices) {
    if (gattServices == null) return;
    generateExportString(gattServices);

    String uuid = null;
    final String unknownServiceString = getResources().getString(R.string.unknown_service);
    final String unknownCharaString = getResources().getString(R.string.unknown_characteristic);
    final List<Map<String, String>> gattServiceData = new ArrayList<>();
    final List<List<Map<String, String>>> gattCharacteristicData = new ArrayList<>();
    mGattCharacteristics = new ArrayList<>();

    // Loops through available GATT Services.
    for (final BluetoothGattService gattService : gattServices) {
        final Map<String, String> currentServiceData = new HashMap<>();
        uuid = gattService.getUuid().toString();
        currentServiceData.put(LIST_NAME, GattAttributeResolver.getAttributeName(uuid, unknownServiceString));
        currentServiceData.put(LIST_UUID, uuid.substring(4,8));
        System.out.println("---service name:"+currentServiceData.get(LIST_NAME));
        System.out.println("---service uuid:" + uuid);
        gattServiceData.add(currentServiceData);

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

        // Loops through available Characteristics.
        for (final BluetoothGattCharacteristic gattCharacteristic : gattCharacteristics) {
            charas.add(gattCharacteristic);
            final Map<String, String> currentCharaData = new HashMap<>();
            uuid = gattCharacteristic.getUuid().toString();
            String property = getPropertyString(gattCharacteristic.getProperties());
            currentCharaData.put(LIST_NAME, GattAttributeResolver.getAttributeName(uuid, unknownCharaString));
            currentCharaData.put(LIST_UUID, uuid.substring(4,8)+" "+property);
            System.out.println("-----char name:" + currentCharaData.get(LIST_NAME));
            System.out.println("-----chat uuid:"+ uuid);
            gattCharacteristicGroupData.add(currentCharaData);
            for (BluetoothGattDescriptor gattDescriptor:gattCharacteristic.getDescriptors()){
                System.out.println("--------des name:" + gattDescriptor.getUuid());
                System.out.println("--------des uuid:" + gattDescriptor.getValue()+" "+gattDescriptor.getPermissions());
            }
        }

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

    final 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);
    invalidateOptionsMenu();
}
项目:Newton_for_Android_AS    文件:HelpFragment.java   
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ExpandableListView helpEx = (ExpandableListView) findViewById(R.id.helpEx);
    // 去掉默认的图标
    helpEx.setGroupIndicator(null);

    Context context = getActivity();

    List<Map<String, String>> groups = new ArrayList<Map<String, String>>();
    Map<String, String> group1 = new HashMap<String, String>();
    group1.put("group", getString(R.string.aboutus));
    Map<String, String> group2 = new HashMap<String, String>();
    group2.put("group", getString(R.string.aboutus));
    Map<String, String> group3 = new HashMap<String, String>();
    group3.put("group", getString(R.string.aboutus));
    Map<String, String> group4 = new HashMap<String, String>();
    group4.put("group", getString(R.string.aboutus));
    groups.add(group1);
    groups.add(group2);
    groups.add(group3);
    groups.add(group4);

    List<Map<String, String>> child1 = new ArrayList<Map<String, String>>();
    Map<String, String> child1data1 = new HashMap<String, String>();
    child1data1.put("child", getString(R.string.aboutus));
    child1.add(child1data1);

    List<Map<String, String>> child2 = new ArrayList<Map<String, String>>();
    Map<String, String> child1data2 = new HashMap<String, String>();
    child1data2.put("child", getString(R.string.aboutus));
    child2.add(child1data2);

    List<Map<String, String>> child3 = new ArrayList<Map<String, String>>();
    Map<String, String> child1data3 = new HashMap<String, String>();
    child1data3.put("child", getString(R.string.aboutus));
    child3.add(child1data3);

    List<Map<String, String>> child4 = new ArrayList<Map<String, String>>();
    Map<String, String> child1data4 = new HashMap<String, String>();
    child1data4.put("child", getString(R.string.aboutus));
    child4.add(child1data4);

    List<List<Map<String, String>>> childs = new ArrayList<List<Map<String, String>>>();
    childs.add(child1);
    childs.add(child2);
    childs.add(child3);
    childs.add(child4);

    SimpleExpandableListAdapter adapter = new SimpleExpandableListAdapter(
            context, groups, R.layout.help_group, new String[] { "group" },
            new int[] { R.id.groupTo }, childs, R.layout.help_child,
            new String[] { "child" }, new int[] { R.id.childTo });

    helpEx.setAdapter(adapter);
    helpEx.setSelector(R.drawable.help_ex_selector);
}
项目:android-diplicity    文件:MainActivity.java   
private void setupNavigation() {
    navigationRootGroups = new ArrayList<Map<String, String>>() {{
        add(new HashMap<String, String>() {{
            put("ROOT_NAME", getResources().getString(R.string.games));
        }});
        add(new HashMap<String, String>() {{
            put("ROOT_NAME", getResources().getString(R.string.users));
        }});
    }};
    navigationChildGroups = new ArrayList<List<Map<String, String>>>();

    List<Map<String, String>> childGroupForFirstGroupRow = new ArrayList<Map<String, String>>(){{
        add(new HashMap<String, String>() {{
            put("CHILD_NAME", getResources().getString(R.string.my_started));
        }});
        add(new HashMap<String, String>() {{
            put("CHILD_NAME", getResources().getString(R.string.my_staging));
        }});
        add(new HashMap<String, String>() {{
            put("CHILD_NAME", getResources().getString(R.string.my_finished));
        }});
        add(new HashMap<String, String>() {{
            put("CHILD_NAME", getResources().getString(R.string.open));
        }});
        add(new HashMap<String, String>() {{
            put("CHILD_NAME", getResources().getString(R.string.started));
        }});
        add(new HashMap<String, String>() {{
            put("CHILD_NAME", getResources().getString(R.string.finished));
        }});
    }};
    navigationChildGroups.add(childGroupForFirstGroupRow);

    List<Map<String, String>> childGroupForSecondGroupRow = new ArrayList<Map<String, String>>(){{
        add(new HashMap<String, String>() {{
            put("CHILD_NAME", getResources().getString(R.string.top_rated));
        }});
        add(new HashMap<String, String>() {{
            put("CHILD_NAME", getResources().getString(R.string.top_reliable));
        }});
        add(new HashMap<String, String>() {{
            put("CHILD_NAME", getResources().getString(R.string.top_quick));
        }});
        add(new HashMap<String, String>() {{
            put("CHILD_NAME", getResources().getString(R.string.top_hated));
        }});
        add(new HashMap<String, String>() {{
            put("CHILD_NAME", getResources().getString(R.string.top_hater));
        }});
    }};
    navigationChildGroups.add(childGroupForSecondGroupRow);

    SimpleExpandableListAdapter navigationListAdapter = new SimpleExpandableListAdapter(
            this,
            navigationRootGroups,
            android.R.layout.simple_expandable_list_item_1,
            new String[] { "ROOT_NAME" },
            new int[] { android.R.id.text1 },
            navigationChildGroups,
            android.R.layout.simple_expandable_list_item_1,
            new String[] { "CHILD_NAME" },
            new int[] { android.R.id.text1 }
    );

    ExpandableListView navigationList = (ExpandableListView) findViewById(R.id.nav_list);
    navigationList.setAdapter(navigationListAdapter);
    connectNavigationList(navigationList);

}
项目:BleDemo    文件:DeviceControlActivity.java   
private void clearUI() {
    mGattServicesList.setAdapter((SimpleExpandableListAdapter) null);
    mDataField.setText(R.string.no_data);
}
项目:wearbooksource    文件:DeviceControlActivity.java   
private void clearUI() {
    mGattServicesList.setAdapter((SimpleExpandableListAdapter) null);
    mDataField.setText(R.string.no_data);
}
项目:wearbooksource    文件:DeviceControlActivity.java   
private void displayGattServices(List<BluetoothGattService> gattServices) {
    if (gattServices == null) return;
    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);
}
项目:itsnat_droid    文件:TestSetupAssetLayout1.java   
private static void defineExpandableListView(TestActivity act, View rootView)
{
    // http://stackoverflow.com/questions/17636735/expandable-listview-in-fragment

    // Resources res = act.getResources();
    ExpandableListView listView = (ExpandableListView) rootView.findViewById(R.id.expanListViewTestId);

    final int NUM_GROUPS = 10;

    final String NAME = "NAME";
    final String IS_EVEN = "IS_EVEN";

    List<Map<String, String>> groupData = new ArrayList<Map<String, String>>();
    for (int i = 0; i < NUM_GROUPS; i++) // 10 grupos
    {
        Map<String, String> curGroupMap = new HashMap<String, String>(); // Grupo
        groupData.add(curGroupMap);
        curGroupMap.put(NAME, "Group " + i);
        // Comentamos el segundo texto del item de grupo porque simple_expandable_list_item_1 sólo tiene text1
        //curGroupMap.put(IS_EVEN, (i % 2 == 0) ? "This group is even" : "This group is odd"); // No se muestra porque
    }

    List<List<Map<String, String>>> childData = new ArrayList<List<Map<String, String>>>();
    for (int i = 0; i < NUM_GROUPS; i++) // 10 grupos
    {
        List<Map<String, String>> children = new ArrayList<Map<String, String>>();
        for (int j = 0; j < 2; j++)
        {
            Map<String, String> curChildMap = new HashMap<String, String>();
            children.add(curChildMap);
            curChildMap.put(NAME, "Child " + i + " " + j);
            curChildMap.put(IS_EVEN, (j % 2 == 0) ? "This child is even" : "This child is odd");
        }
        childData.add(children);
    }

    // Set up our adapter
    SimpleExpandableListAdapter mAdapter = new SimpleExpandableListAdapter(act, groupData, android.R.layout.simple_expandable_list_item_1, // https://github.com/android/platform_frameworks_base/blob/master/core/res/res/layout/simple_expandable_list_item_1.xml
            new String[]{NAME}, //new String[] { NAME, IS_EVEN },
            new int[]{android.R.id.text1}, // new int[] { android.R.id.text1, android.R.id.text2 },
            childData, android.R.layout.simple_expandable_list_item_2, // https://github.com/android/platform_frameworks_base/blob/master/core/res/res/layout/simple_expandable_list_item_2.xml
            new String[]{NAME, IS_EVEN}, new int[]{android.R.id.text1, android.R.id.text2});

    listView.setAdapter(mAdapter);
}
项目:binea_project_for_android    文件:DeviceControlActivity.java   
private void clearUI() {
    mGattServicesList.setAdapter((SimpleExpandableListAdapter) null);
    mDataField.setText(R.string.no_data);
}
项目:binea_project_for_android    文件:DeviceControlActivity.java   
private void displayGattServices(List<BluetoothGattService> gattServices) {
    if (gattServices == null) return;
    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);
}