first the variable builder
is not initialized as onCreateDialog()
is not called any where...
You may be thinking that you are overriding onCreateDialog()
method of Activity
but actually not.
see the definition of onCreateDialog()
in Activity
protected Dialog onCreateDialog(int);
protected Dialog onCreateDialog(int,Bundle);
FYI... these two methods are deprecated.
but you wrote
protected Dialog onCreateDialog(Bundle);
which does not override any method of Activity
...(use Override
annotation to know you are actually overriding or not)
You can remove the Bundle
parameter from onCreateDialog()
method as you are not using it.
public Dialog onCreateDialog() {
// TODO Auto-generated method stub
builde = new AlertDialog.Builder(Placed_Product_Details.this);
LayoutInflater inflater = Placed_Product_Details.this
.getLayoutInflater();
// Inflate and set the layout for the dialog
// Pass null as the parent view because its going in the dialog layout
builde.setView(inflater.inflate(R.layout.updateproductname, null))
// Add action buttons
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
// sign in the user ...
}
});
return builde.create();
}
and call this method when appropriate MenuItem
is clicked...
case R.id.updateproductname:{
//here I have created a dialog and called it here. The code
//of the dialog is posted above
onCreateDialog().show();
break;
}