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

0

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(R.id.btnIngenieria);
        btnInge.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Fragment fragment = new FragmentIngenieria();
                FragmentTransaction transaction = getFragmentManager().beginTransaction();
                transaction.replace(R.id.content_main,fragment);
                transaction.commit();
            }
        });
    
asked by Fer Fernandez 13.12.2018 в 19:30
source

1 answer

0

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