0

Error message:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.basket/com.example.basket.MainActivity}: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.example.basket.MainActivity$TabContentFragment: make sure class name exists, is public, and has an empty constructor that is public

Fragment Class:

public class TabContentFragment extends Fragment {
    public TabContentFragment()
    {

    }
    private String mText;
    public TabContentFragment(String text) {
        mText = text;
    }
    public String getText() {
        return mText;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {      
        View fragView = inflater.inflate(R.layout.action_bar_tab_content,                  container, false);                     
        mlistView= (ListView) fragView.findViewById(R.id.postListView); 
        getData(mText);
        return fragView;
    }

}
Psypher
  • 10,717
  • 12
  • 59
  • 83
user1445018
  • 117
  • 1
  • 6

1 Answers1

0

Is that fragment an inner class? If so you will need to make that inner class static.

See here: Unable to instantiate fragment make sure class name exists, is public, and has an empty constructor that is public

Community
  • 1
  • 1
lostintranslation
  • 23,756
  • 50
  • 159
  • 262