onCreate() and onCreateView() invokes a lot more than required (Fragments)

I can’t point to the documentation which explains this, but the solution is to only create and add the fragment when the activity first loads, like this:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    if (savedInstanceState == null) {
        Fragment fg = new Right();
        getFragmentManager().beginTransaction().add(R.id.right_frag, fg)
            .commit();
    }
    Log.i("Main", "onCreate()");
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)