So I created a Navigation Drawer Activity and some fragments. On one fragment I have a textView in which I need to show the date like dd.MM.yyyy I managed to do this on a different app using:
//show date
TextView datumprikaz = (TextView)findViewById(R.id.datumprikaz);
Date danas = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");
String novDatum = sdf.format(danas);
datumprikaz.setText(novDatum);
//End of show date
But when I use it now in my MainActivity.java it shows the error:
Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference
This is the error log, MainActivity.java and my fragment.xml (ignore the big code, the date part is one line) :
https://gist.github.com/anonymous/f19acb835b43111f576bef2791c4a28e