No Open the Fragment, I thunders when I open it with a button


I am new to the use of Fragments, and I have a doubt, I do not know why when I click on a button, I do not open the Fragment that I invoke .. I already look for several solutions but I continue with the same thing, I thunders here I leave the code ...

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) 
        view = inflater.inflate(R.layout.fragment_fragment_entidades, container, false);

        btnInge = (Button) view.findViewById(;
        btnInge.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                Fragment fragment = new FragmentIngenieria();
                FragmentTransaction transaction = getFragmentManager().beginTransaction();
asked by Fer Fernandez 13.12.2018 в 19:30

1 answer


Possibly your error is when creating the Fragment object:

Fragment fragment = new FragmentIngenieria();

Try placing:

FragmentIngenieria fragment = new FragmentIngenieria();
answered by 16.12.2018 в 17:11