在片段中,单击按钮时,它们将打开不同的片段。单击signup_b时,将打开新的片段,但是单击signin_b时,将不打开新的片段。
public void onViewCreated(final View view, @Nullable Bundle savedInstanceState) {
signin_b = view.findViewById(R.id.sign_in_button);
signup_b = view.findViewById(R.id.sign_up_button);
//signin_b.setOnClickListener(this);
//signup_b.setOnClickListener(this);
signup_b.setOnClickListener(new View.OnClickListener() {
public void onClick (View v){
question = new RegisterQuestionFragment();
getFragmentManager().beginTransaction().replace(R.id.main_fragment,question,"information").addToBackStack(null).commit();
}
});
signin_b.setOnClickListener(new View.OnClickListener() {
public void onClick (View v){
log = new LoginFragment();
getFragmentManager().beginTransaction().replace(R.id.main_fragment,log,"log").addToBackStack(null).commit();
}
});
}