I am new to android and learning from developer.android.com. As per their tutorial I am trying to get my textView from the Fragment like this.
@Override
public View onCreateView(
LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState
) {
// Inflate the layout for this fragment
View fragmentFirstLayout = inflater.inflate(R.layout.fragment_first, container, false);
// Get the text view
showCountTextView = (TextView) fragmentFirstLayout.findViewById(R.id.textview_first);
return fragmentFirstLayout;
}
And this builds successfully but crashes as soon as launched. Any idea what is wrong. The log says like this.
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapp/com.example.myapp.MainActivity}: android.view.InflateException: Binary XML file line #23 in com.example.myapp:layout/activity_main: Binary XML file line #8 in com.example.myapp:layout/content_main: Error inflating class fragment