Class Extending Fragment - Error Says Make Sure Class Name Exists, Is Public, And Has An Empty Constructor That Is Public
I have a class like this: class TopicFragment extends Fragment{ public TopicFragment(VO vO) { // some code } } Users are reporting that the app is crashing and the log
Solution 1:
Just simply add an empty constructor with no parameters which is public. if you have the fragment set in XML without an empty constructor it cannot be created.
publicTopicFragment() {
}
I also usually always have just the empty constructor and have a method like this to instantiate with arguments
publicstatic TopicFragment newInstance(VO vo) {
TopicFragmentfragment=newTopicFragment();
fragment.setVo(vo);
return fragment;
}
EDIT: and as the guys said in the comments make your class:
publicclassTopicFragment {
}
Post a Comment for "Class Extending Fragment - Error Says Make Sure Class Name Exists, Is Public, And Has An Empty Constructor That Is Public"