Getting values of edit text error NULLPOINTER why? [closed]
I'm trying to get text from values of edit field showed on a dialog and save it in a variable. final Dialog dialog = new Dialog(context); dialog.setContentView(R.layout.dialg); dialog.setTitle("Title..."); dialog.show(); Button dialogButtonCancel = (Button) dialog.findViewById(R.id.cancel); // if button is clicked, close the custom dialog dialogButtonCancel.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dialog.dismiss();}}); Button dialogButtonOK = (Button) dialog.findViewById(R.id.OK); //**********************************************************************