Click here to Skip to main content
15,895,772 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Dialog d = new Dialog(null);
				d.setTitle("hi");
				d.show();

			}
		});

i use this code but when i click the button it displays the error.
Posted

You'll want to use the Builder class on the dialog to create your dialog.

This might work for you;

Java
new AlertDialog.Builder(this)
    .setTitle("Dialog Title")
    .setMessage("Do you want to do this?")
    .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            // Code for when user clicks Yes
        }
     })
    .setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            // Code for when user clicks No
    }
     })
    .show();


You can chain loads of other calls there to set things like icon other things (or not set No button for example).

Hope this helps,
Fredrik
 
Share this answer
 
Comments
prakash firefox 2-Jul-14 12:41pm    
it show no suggestion error on eclipse.. i using 4.2 and api 17 for my application..
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900