Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialOrkan Igxhi
858 PointsHow to fix ???
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSeq
Orkan Igxhi
858 PointsHey there,
I'm struggling in the part where we start to populate the data on the main activity exactly within the runnable triggered from runOnUiThread, inside the run() { whenever I set the command to set the text of an injected/binded textview text the error throws. It seems like the run puts the updateDisplay() in a scope which it can't access backwards the textviews below:
@BindView(R.id.timeLable) TextView mTimeLabel; @BindView(R.id.temperatureLabel) TextView mTemperatureLabel; @BindView(value = R.id.humidityLabel) TextView mHumidityValue; @BindView(R.id.preicpLabel) TextView mPrecipValue; @BindView(R.id.summaryLabel) TextView mSummaryLabel; @BindView(R.id.iconImageView) ImageView mIconImageView;
runOnUiThread(new Runnable() { @Override public void run() { updateDisplay(); } }
1 Answer
Seth Kroger
56,413 PointsFirst make sure you're configuring ButterKnife in gradle according to the current instructions: https://github.com/JakeWharton/butterknife#download
Seth Kroger
56,413 PointsSeth Kroger
56,413 PointsNullPointerExecptions have many possible causes. What course/project are you doing and what is your code?
[Switching subject to Android]