Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/187.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android-ExpandableListView中的启动意图_Android_Expandablelistview_Android Intent - Fatal编程技术网

Android-ExpandableListView中的启动意图

Android-ExpandableListView中的启动意图,android,expandablelistview,android-intent,Android,Expandablelistview,Android Intent,我试图弄清楚是否有可能在ExpandableListView中启动一个意图。基本上,其中一个组是电话号码,它的子组是号码。我希望用户能够点击它,并让它自动呼叫该号码。这可能吗?怎么做 下面是我使用名为data的映射填充ExpandableListView的代码 ExpandableListView myList = (ExpandableListView) findViewById(R.id.myList); //ExpandableListAdapter ada

我试图弄清楚是否有可能在ExpandableListView中启动一个意图。基本上,其中一个组是电话号码,它的子组是号码。我希望用户能够点击它,并让它自动呼叫该号码。这可能吗?怎么做

下面是我使用名为data的映射填充ExpandableListView的代码

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);
您可以向可展开列表视图中添加。当调用OnChildClick时,您拥有组和子位置,因此您应该能够确定单击了哪个电话号码

然后,您只需发出打电话的意图,即:

Intent intent = new Intent(Intent.CALL_ACTION);
intent.setData(Uri.parse("tel:+436641234567"));
startActivity(intent);