简体   繁体   中英

Different Fragments showing the same content

I've created an activity with three fragments .the first fragment works fine , the second too , but the third shows the same content as the second fragment .

I don't see where the problem is , I have : ( where deletecase is the 3rd fragment xml file )

View rootView = inflater.inflate(R.layout.deletecase, container, false);

and for the second :

View rootView = inflater.inflate(R.layout.updatecase, container, false);

and for each fragment I have a nested class .

How can I solve this ?

EDIT

I just relised that I forgot to do this :p

public Fragment getItem(int position) {
            // getItem is called to instantiate the fragment for the given page.
            // Return a NewCaseFragment (defined as a static inner class
            // below) with the page number as its lone argument.

            if (position == 0) {
                Fragment fragment = new NewCaseFragment();
                // Bundle args = new Bundle();
                // args.putInt(NewCaseFragment.ARG_SECTION_NUMBER, position +
                // 1);
                // fragment.setArguments(args);
                return fragment;

            } else if (position == 1){
                Fragment fragment = new UpdateFragment();
                return fragment;
            }

            else {
                Fragment fragment = new DeleteFragment();
                return fragment;
            }
        }

thanks all for your answers .

您是否验证了设计是否相同,但ID是否不同?

What about the main layout, the one with three fragment. Are you sure the android:name (or class) attribute are different for the second and the third fragments ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM