R.id.test_fragment is not the ID of your fragment but the id of your LinearLayout
add(int containerViewId, Fragment fragment) will add a fragment without a tag.
So or you use
add(int containerViewId, Fragment fragment, String tag) and you get back your fragment using your tag (as an ID)
- Send data from activity to fragment in Android
- Best practice for instantiating a new Android Fragment
- How to correctly save instance state of Fragments in back stack?
- Update ViewPager dynamically?
- How to handle button clicks using the XML onClick within Fragments
- Communicating between a fragment and an activity – best practices
- How to put Google Maps V2 on a Fragment using ViewPager
- getActivity() returns null in Fragment function
- Do fragments really need an empty constructor?
- How to implement OnFragmentInteractionListener
- How to pass data between fragments
- Getting the current Fragment instance in the viewpager
- Fragments within Fragments
- Error inflating class fragment
- How to resume existing Fragment from BackStack
- Getting the error “Java.lang.IllegalStateException Activity has been destroyed” when using tabs with ViewPager
- Calling a Fragment method from a parent Activity
- Activity, AppCompatActivity, FragmentActivity, and ActionBarActivity: When to Use Which?
- MapView in a Fragment (Honeycomb)
- How to get existing fragments when using FragmentPagerAdapter
- How to implement RecyclerView with CardView rows in a Fragment with TabLayout
- Why use Fragment#setRetainInstance(boolean)?
- How to clear navigation Stack after navigating to another fragment in Android
- getView returning null when fragment has been created from an activity
- Get the current fragment object
- Fragment is not being replaced but put on top of the previous one
- Show DialogFragment with animation growing from a point
- How to use setArguments() and getArguments() methods in Fragments?
- Best practice for nested fragments in Android 4.0, 4.1 (
- How do you create Preference Activity and Preference Fragment on Android?
- Android – save/restore fragment state
- Adding button action in custom notification
- Difference between Activity and FragmentActivity
- How to pass Bundle from Fragment to Fragment
- Alternatives to PreferenceFragment with android-support-v4
- Android ViewPager get the current View
- Sending data from nested fragments to parent fragment
- How to listen for preference changes within a PreferenceFragment?
- Cannot call getSupportFragmentManager() from activity
- When a Fragment is replaced and put in the back stack (or removed) does it stay in memory?
- Position of DialogFragment in Android
- application content goes behind the navigation bar in android L
- Why use Fragments? [duplicate]
- findFragmentByTag() returns null after perform a FragmentTransaction using replace() method
- Error inflating class android.support.design.widget.CoordinatorLayout and ClassNotFoundException: android.support.design.R$styleable
- How to replace a Fragment on button click of that fragment?
- Android ViewPager padding/margin between page fragments
- How to replace the activity’s fragment from the fragment itself?
- When to use FragmentManager::putFragment and getFragment
- Data Sharing between Fragments and Activity in Android