Fragments Incompatible types

There Activity inherits ActoinBarActivity, it describes the sidebar (NavigationDrawer), by clicking on its elements open fragments. In one of the fragments have listView, by clicking on the item which I want to open another fragment ( staff- a list of employees – employee data). But I is an error

Incompatible types:

  • detect keyboard search button
  • How to programmatically initiate a Google Now voice search?
  • HTTP Patch request from Android
  • How to get time and Date from datetime stamp
  • Gallery/AdapterView Child Drawable State
  • How to retrieve HTML content from WebView (as a string)
  • public class MyEmployeeFragment extends Fragment {
    //some code
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
    Bundle savedInstanceState) {
        userList = new ArrayList<User>();
        sAdapter = new CustomAdapter(getActivity(),userList);
        View rootView = inflater.inflate(R.layout.my_employe, container, false);
        ListView lv = (ListView)rootView.findViewById(;
        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view,
            int position, long id) {
                Fragment f = new EmployeeDetails(); // ERROR
                FragmentManager fragmentManager = getFragmentManager();
                FragmentTransaction ft = fragmentManager.beginTransaction();
                ft.replace(, f);
                Log.i("TAG", "itemClick: position = " + position + ", id = "
                + id);


    public class EmployeeDetails extends Fragment {
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                 Bundle savedInstanceState) {
            // Inflate the layout for this fragment
            return inflater.inflate(R.layout.fragment_employee_details, container, false);

    Answer is:

    All fragments must import; not;

    Related posts:

    Custom selected tab text color in SlidingTabLayout
    Android circular seekbar
    Can I make a button appear disabled and still listen for clicks?
    Scene transition with hero elements throws Layer exceeds max. dimensions supported by the GPU
    Gradle Execution failed for task &#039;:app:dexDebug&#039; with new Android Studio Project
    How does the Android Market work for developers?
  • Share link and text with Android Facebook SDK 3.0
  • Is it possible to create a custom state for use in a StateListDrawable?
  • How to find whether activity is last activity in stack
  • Launch google maps application for driving directions in android
  • Android activity recreate itself
  • How to use Flipboard effect on Android
  • 2 Solutions collect form web for “Fragments Incompatible types”

    In your class EmployeeDetails declaration, do this:

    public class EmployeeDetails extends Fragment {

    And use import;

    not use import;

    Use import;
    Its Working me.

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.