Im trying to get the TextViews shown in my faq_fragment.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/question_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textAlignment="center"
android:text="Title 1"/>
<TextView
android:id="@+id/answer_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textAlignment="center"
android:text="Description 1"
android:textColor="#33000000"
android:layout_marginTop="5dp"/>
</LinearLayout>
In my Fragment class
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
((TextView)container.findViewById(R.id.question_text)).setText(title);
((TextView)container.findViewById(R.id.answer_text)).setText(description);
return inflater.inflate(R.layout.faq_fragment, container, false);
}
App is crashing and Im getting error:
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference