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



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

使用此链接。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

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

你可以像这个一样

 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;
        }
    });

最新更新