The google documentation says that I can "call methods in the fragment by acquiring a reference to the Fragment from FragmentManager, using findFragmentById()"
This part makes sense:
SelectionFragment fragment = (SelectionFragment) getSupportFragmentManager().findFragmentById(R.id.selectionFragment);
What I don't understand is how I am actually now supposed to call the methods. I've tried everything I can think of. I tried this, and I get a Null Pointer Exception on this line:
String fbID = fragment.userIdView.getText().toString();
I know there are a TON of questions on stack overflow about findFragmentById returning null, but I haven't found a solution in any of them. I have no idea how to identify where the problem is.
To be clear, selectionFragment is the ID of my fragment set in the xml:
<fragment android:name="com.example.androidhive.SelectionFragment"
android:id="@+id/selectionFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />