如何使用确认对话框调用listview?

时间:2015-03-24 11:52:24

标签: java android

我想向用户显示确认对话框,当用户点击是按钮打开列表视图进行选择时。

2 个答案:

答案 0 :(得分:0)

你可以这样

 Listview.setOnItemClickListener(new AdapterView.OnItemClickListener()
    {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id)
        {
            build = new AlertDialog.Builder(YourActivity.this);
            build.setTitle("Title name");
            build.setMessage("?");
            build.setPositiveButton("Yes", new DialogInterface.OnClickListener()
            {
                public void onClick(DialogInterface dialog, int which)
                {
                    //IF yes button pressed then write here
                    }
                   dialog.cancel();
                }
            });

            build.setNegativeButton("No", new DialogInterface.OnClickListener()
            {
                public void onClick(DialogInterface dialog, int which)
                {
                    dialog.cancel();
                }
            });
            AlertDialog alert = build.create();
            alert.show();
            return true;
        }
    });

答案 1 :(得分:0)

使用此链接..............................

http://rajeshvijayakumar.blogspot.in/2013/04/alert-dialog-dialog-with-item-list.html