Good day. There is such a method:
public void createURLLinkDialog(){ final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); final LayoutInflater inflater = getActivity().getLayoutInflater(); builder.setView(inflater.inflate(R.layout.dialog_url, null)) .setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { EditText et = (EditText) getActivity().findViewById(R.id.push_url_link); //TODO: ERROR ON BUTTON CLICK! urlToImage = et.getText().toString(); } }); builder.create(); builder.show(); } Actually, the point is that this method lies in the fragment that lies in the container of activation. As can be seen from the method, own custom markup is used for the dialogue. How to access the xml markup elements of the created dialog from the fragment?
Stacktrace
java.lang.NullPointerException: Attempt to invoke virtual method 'android.text.Editable android.widget.EditText.getText()' on a null object reference at ru.timuruktus.newsletters.View.Fragments.PushPostFragment$3.onClick(PushPostFragment.java:165)