public static class PlaceholderFragment extends Fragment {
public PlaceholderFragment() { }
@Override
public View onCreateView(
LayoutInflater inflater,
ViewGroup container,
Bundle saveInstanceState) {
View rootView =
inflater.inflate(R.layout.fragment_main, container, false);
Button btnNumberGuessGame =
rootView.findViewById(R.id.btnNumberGuessGame);
btnNumberGuessGame.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent =
new Intent(getActivity(), NumberGuessGame.class);
getActivity().startActivity(intent);
}
});
return rootView;
}
}
You are not calling another screen, theoretically the code is "right."