Gaurav Agarwal
Gaurav Agarwal

Reputation: 19102

FragmentActivity not calling ListFragment

I am trying to implement a ListFragment. The idea is to use CursorLoader. The code for FragmentActivity is

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

        FragmentManager fm = getSupportFragmentManager();

        // Create the list fragment and add it as our sole content.
        if (fm.findFragmentById(android.R.id.content) == null) {
            XYZFragment list = new XYZFragment();
            fm.beginTransaction().add(android.R.id.content, list).commit();
        }
} 

Now I assume that onActivityCreate of XYZFragment should be called but that is not happening instead I am getting a the below image on the Emulator. I am looking for an explanation as to what is happening and what I am doing wrong?

Thanks.

enter image description here

Upvotes: 0

Views: 989

Answers (1)

Alex Lockwood
Alex Lockwood

Reputation: 83303

Change onActivityCreate to onActivityCreated and you should get the expected results.

Upvotes: 1

Related Questions