How to access an item inside a DialogFragment? In my dialogue (View) there are also input fields when I try to access them in the "standard way" (as usual I refer to the elements of the fragment):
EditText text = (EditText)getActivity().findViewById(R.id.number_n); I get an exception that text = null and I can't access this element.
'void android.widget.TextView.setText (java.lang.CharSequence)' on a null object reference
Below is the source of the fragment itself.
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { form = getActivity().getLayoutInflater() .inflate(R.layout.loginform, null); EditText text = (EditText)getActivity().findViewById(R.id.number_n); text.setText("123"); AlertDialog.Builder builder=new AlertDialog.Builder(getActivity()); return(builder.setTitle("Форма смены пользователя").setView(form) .setPositiveButton("Ок", this) .setNegativeButton("Отмена", null) .setNeutralButton("Забыли пароль?", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { Toast.makeText(getActivity().getApplicationContext(), "remember", Toast.LENGTH_SHORT).show(); new CustomDialogFragmentRemember().show(getActivity().getFragmentManager(), "remember"); } }) .create()); }
text == nullor not. Clearly says thattext = null. As for the question, I do not see anytextView.setText()- DevOma