1

I am following this tutorial http://www.androidhive.info/2013/11/android-sliding-menu-using-navigation-drawer/

Now This is my fragment,and here I am able to see navigation drawer,Now from this fragment I Intent to next activity and I want to display navigation drawer in that activity

public class WhatsHotFragment extends Fragment {

public WhatsHotFragment(){}


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

    View rootView = inflater.inflate(R.layout.fragment_whats_hot, container, false);
     txtchs=(Button)rootView.findViewById(R.id.txtcheking);


    txtchs.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent=new Intent(getActivity(),AllProducts.class);
            startActivity(intent);
        }
    });
    return rootView;
}
}

The issue is I want to access navigation drawer in Allproducts activity..so is it possible?can anyone help?

Aditya
  • 1,508
  • 1
  • 19
  • 37
  • Call child `Fragment` instead of `Activity`. – Piyush Jun 01 '15 at 07:05
  • Mean you need to call another fragment on button click which include navigation drawer in it. – Piyush Jun 01 '15 at 07:17
  • yes exactly so how to do that..?can you tell – Aditya Jun 01 '15 at 07:19
  • `Fragment frag = new YourFragment(); FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.replace(R.id.fragment_container, frag); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); ft.addToBackStack(null); ft.commit();` on button click you need to call this – Piyush Jun 01 '15 at 07:22
  • thats awesome..will put it as answer,,so that i can accept.. – Aditya Jun 01 '15 at 07:34

1 Answers1

1

Call this code on button click.

Fragment frag = new YourFragment(); 

FragmentTransaction ft = getFragmentManager().beginTransaction(); 

ft.replace(R.id.fragment_container, frag);  

ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); 

ft.addToBackStack(null); 

ft.commit();
Piyush
  • 18,895
  • 5
  • 32
  • 63