Android - Launch Intent within ExpandableListView
- by Ryan
Hello,
I'm trying to figure out if it is possible to launch an intent within an ExpandableListView. Basically one of the "Groups" is Phone Number and it's child is the number. I want the user to be able to click it and have it automatically call that number. Is this possible? How?
Here is my code to populate the ExpandableListView using a Map called "data".
ExpandableListView myList = (ExpandableListView) findViewById(R.id.myList);
//ExpandableListAdapter adapter = new MyExpandableListAdapter(data);
List<Map<String, String>> groupData = new ArrayList<Map<String, String>>();
List<List<Map<String, String>>> childData = new ArrayList<List<Map<String, String>>>();
Iterator it = data.entrySet().iterator();
while (it.hasNext())
{
//Get the key name and value for it
Map.Entry pair = (Map.Entry)it.next();
String keyName = (String) pair.getKey();
String value = pair.getValue().toString();
//Add the parents -- aka main categories
Map<String, String> curGroupMap = new HashMap<String, String>();
groupData.add(curGroupMap);
curGroupMap.put("NAME", keyName);
//Add the child data
List<Map<String, String>> children = new ArrayList<Map<String, String>>();
Map<String, String> curChildMap = new HashMap<String, String>();
children.add(curChildMap);
curChildMap.put("NAME", value);
childData.add(children);
}
// Set up our adapter
mAdapter = new SimpleExpandableListAdapter(
mContext,
groupData,
R.layout.exp_list_parent,
new String[] { "NAME", "IS_EVEN" },
new int[] { R.id.rowText1, R.id.rowText2 },
childData,
R.layout.exp_list_child,
new String[] { "NAME", "IS_EVEN" },
new int[] { R.id.rowText3, R.id.rowText4}
);
myList.setAdapter(mAdapter);