Próbuję dodać fragment do mojego kontenera fragmentu FrameLayout

Stworzyłem plik xml o nazwie editor.xml, który zawiera FrameLayout. W mojej głównej działalności próbuję dodać mój własny fragment do mojego FrameLayout.

Błąd, który otrzymuję podczas próby dodania mojego fragmentu, to:

Metoda add (int, Fragment) w typie FragmentTransaction nie ma zastosowania do argumentów (int, editorFrag)

Jednak mój edytor Frrag rozszerza Fragment, więc jestem zdezorientowany, dlaczego tak się dzieje. Poniżej znajduje się mój kod dla plików, o których wspomniałem. Każda pomoc jest doceniana.

Editor.xml

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />

editorFrag.java

public class editorFrag extends Fragment
{
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, 
        Bundle savedInstanceState) 
    {

        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.newlevel, container, false);
    }
}

MainActivity.java

public class editorActivity extends FragmentActivity
{
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.editor);

        // Check that the activity is using the layout version with the fragment_container FrameLayout
        if(findViewById(R.id.fragment_container) != null)
        {
            // if we are being restored from a previous state, then we dont need to do anything and should
            // return or else we could end up with overlapping fragments.
            if(savedInstanceState != null)
                return;

            // Create an instance of editorFrag
            editorFrag firstFrag = new editorFrag();

            // add fragment to the fragment container layout
            getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, firstFrag);
        }
    } 
}

Odpowiedzi:

Luksprog odpowiedział mi na ten problem poniżej, mówiąc mi, abym sprawdził import. Eclipse zdecydował się zaimportować wersję Fragmentu SDK zamiast potrzebnej wersji wsparcia. Dziękuję za pomoc.

questionAnswers(3)

yourAnswerToTheQuestion