Nullpointerexception While Changing Textview Text In An Alertdialog
Background: I just want to create a customDialog with a specific layout and add the content. Its a DialogFragment Code: TextView text; @Override public void onCreate(Bundle save
Solution 1:
At first i thought its a Activity
now i see its a DialogFragment
.
I am guessing the view belongs to custom_dialog.xml
Viewview= inflater.inflate(R.layout.custom_dialog, null);
text = (TextView)view.findViewById(R.id.lorem);
builder.setView(view);
So use the view object to initialize TextView
.
text = (TextView)getView().findViewById(R.id.lorem);
here getView()
returns null.
You are calling setText
on null leading to NullPointerException
.
Post a Comment for "Nullpointerexception While Changing Textview Text In An Alertdialog"