Aditya
Aditya

Reputation: 1518

How to access navigation drawer in all activities?

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?

Upvotes: 1

Views: 725

Answers (1)

Piyush
Piyush

Reputation: 18933

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();

Upvotes: 1

Related Questions