So i'm trying to display a TextView
whenever a user clicks an item on a ListView
. However, when i click a list item, i get this error...
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference
.
What causes this to occur in regards to "TextViews" specifically and are there any possible solutions to solving it? Thanks.
Update
Here's how i set the TextViews..
Activity
@Override
public void onTextFooterListener(String String1, String String2) {
tab1.setLabels(String1, String2);
}
Tab1Fragment
public void setLabels(String mString1, String mString2) {
title1 = mString1;
title2= mString2;
title1Footer.setText(title1);
title2Footer.setText(title2);
updateTimerLabel();
}
TextViews
title1Footer= (TextView) rootView.findViewById(R.id.title1_footer);
title2Footer= (TextView) rootView.findViewById(R.id.title2_footer);
tab1
is declared as public Tab1Fragment tab1 = new Tab1Fragment();
If i comment out the onTextFooterListener
, the code seems to work just fine...