You dont call setContentView
in fragments, in fact you need to return a View
from onCreateView
.
Try replacing:
setContentView(new SampleView(this));
With this:
return new SampleView(this);
More Related Contents:
- Can I use view pager with views (not with fragments)
- What is the benefit of using Fragments in Android, rather than Views?
- How to determine when Fragment becomes visible in ViewPager
- Do fragments really need an empty constructor?
- IllegalStateException: Can not perform this action after onSaveInstanceState with ViewPager
- How to transfer some data to another Fragment?
- Dilemma: when to use Fragments vs Activities:
- Android View.getDrawingCache returns null, only null
- Refresh Fragment at reload
- Android Fragment onAttach() deprecated
- How to implement RecyclerView with CardView rows in a Fragment with TabLayout
- Android Fragments. Retaining an AsyncTask during screen rotation or configuration change
- Add and Remove Views in Android Dynamically?
- Hide/Show bottomNavigationView on Scroll
- Android AppCompat 21 Elevation
- PreferenceFragmentCompat requires preferenceTheme to be set
- onClickListener does not work in fragment
- How to wrap the height of a ViewPager to the height of its current Fragment?
- refresh fragment UI from fragmentActivity
- Android – save/restore fragment state
- No resource identifier found for attribute ‘…’ in package ‘com.app….’
- Coordinator Layout with Toolbar in Fragments or Activity
- findFragmentById always returns null
- How to replace the activity’s fragment from the fragment itself?
- Use external application fragment/activity inside application
- Is there a method that works like start fragment for result?
- Replacing ViewPager with Fragment – Then Navigating Back
- Why isn’t there a getContentView() method for Activity?
- Fragment standard transition not animating
- Kotlin: open new Activity inside of a Fragment