0

ExpandableListView内でインテントを起動できるかどうかを調べようとしています。基本的に「グループ」の1つは電話番号であり、その子は番号です。ユーザーがそれをクリックして、自動的にその番号に電話をかけることができるようにしたいと思います。これは可能ですか?どのように?

これは、「データ」と呼ばれるマップを使用して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);
4

1 に答える 1

0

OnChildClickListenerを展開可能なリストビューに追加できます。OnChildClickが呼び出されると、グループと子の位置がわかるため、クリックされた電話番号を把握できるはずです。

次に、電話をかける意図を解き放つ必要があります。つまり、次のようになります。

Intent intent = new Intent(Intent.CALL_ACTION);
intent.setData(Uri.parse("tel:+436641234567"));
startActivity(intent);
于 2010-05-28T16:47:55.457 に答える