Unable to instantiate fragment make sure class name exists, is public, and has an empty constructor that is public
Is it because my Fragment is not a static class? Is it because my Fragment is an inner class?
If I make my Fragment a static class, all my references to findViewById fail, which means a LOT of refactoring.
How can I solve this without turning my inner Fragment into a static class?
is it because my Fragment is an inner class
If your fragment is an inner class, it must be a static inner class. Ideally, it's a standalone public Java class.
if I make my Fragment a static class, all my references to findViewById fail, which means a LOT of refactoring
You needed to do that refactoring anyway. Widgets are now owned by the fragment, not the activity. Fragments should know as little as possible about what activity contains them, so they can be shuffled between different activities as needed to support phones, tablets, TV, etc.
How can I solve this without turning my inner Fragment into a static class??
You make it a standalone public Java class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With