Navigator Drawer on fragments

0

I am using a navigation drawer and in a fragment I have something like a menu, with different buttons which when pressing each one of those buttons takes you to a fragment with different content, to achieve this I put the code below, What happens is that when pressing two buttons of the 5 the content of the fragment is over with the fragment of the "menu", (where are the buttons), I do not know because since it uses the same code for all the buttons it works in the others less in two.

XML:

 <Button
     android:id="@+id/boton3"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:text="Consultar Reporte"
     android:background="@android:color/transparent" />

JAVA:

Button boton03;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
    Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.fragment_home, container, false);
    boton03 = (Button) view.findViewById(R.id.boton3);

    boton03.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Fragment fragment = new Reportes();
            FragmentTransaction transaction = getFragmentManager().beginTransaction();
            transaction.add(R.id.content_main, fragment);
            transaction.addToBackStack(null);
            transaction.commit();
        }
    });

    return view;
}
    
asked by Daniel Prado 04.10.2017 в 06:30
source

1 answer

0

You need to add a color to the fragments' xml background so they do not look "transparent", or try this:

android:background="?android:colorBackground"
    
answered by 06.10.2017 / 23:04
source