Skip to content

Instantly share code, notes, and snippets.

@codingpizza
Created April 9, 2018 18:59
Show Gist options
  • Save codingpizza/448a70c1910f9580ebe6f007d4d5532c to your computer and use it in GitHub Desktop.
Save codingpizza/448a70c1910f9580ebe6f007d4d5532c to your computer and use it in GitHub Desktop.
MainActivity con fragments
package codingpizza.com.cda7;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity implements LoginFragment.onSignUpSelectedListener {
private FragmentManager mFragmentManager;
private LoginFragment mLoginFragment;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mLoginFragment = new LoginFragment();
mFragmentManager = getSupportFragmentManager();
mFragmentManager.beginTransaction()
.add(R.id.fragment_container, mLoginFragment)
.commit();
}
@Override
public void onSignUpSelected() {
SignInFragment signInFragment = new SignInFragment();
mFragmentManager.beginTransaction()
.replace(R.id.fragment_container, signInFragment)
.commit();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment