从expandableListviewGroup保留打开弹出对话框

问题描述 投票:0回答:1

我有问题,无法使用Google找到任何帮助。单击时,我有一个可扩展的列表视图,其中包含一些信息。现在,我想添加一些东西,如在按住groupitem时显示的弹出对话框。

有人知道怎么做吗?

这是我现在的代码:

    setContentView(R.layout.activity_main);
    cocktailView=(ExpandableListView)findViewById(R.id.simple_cocktail_list);
    cocktailHash = new HashMap<>();

    final RequestQueue requestQueue = Volley.newRequestQueue(this);

    final StringRequest objectRequest = new StringRequest(
            Request.Method.GET,
            "http://datservice/all/cocktails",
            new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                    JsonElement element = new JsonParser().parse(response);
                    cocktailList = new Gson().fromJson(element.getAsJsonArray(), new TypeToken<List<Cocktail>>() {}.getType());
                    onSuccess(cocktailList);
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    String test = error.toString();
                    //Log.e("Rest Response", error.toString());
                }
            }
    );
android expandablelistview smartphone
1个回答
0
投票
子项上捕获long click。基于此答案,您还可以在

group item上捕获long click。这是一个例子,

cocktailView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { if (ExpandableListView.getPackedPositionType(id) == ExpandableListView.PACKED_POSITION_TYPE_GROUP) { // Show your pop up dialog new AlertDialog.Builder(view.getContext()) .setMessage("Your Message") .show(); return true; } return false; } });
© www.soinside.com 2019 - 2024. All rights reserved.