我正在关注本教程http://www.androidhive.info/2013/11/android-sliding-menu-using-navigation-drawer/
现在这是我的片段,在这里我可以看到导航抽屉,现在从这个片段我想进入下一个活动,我想在该活动中显示导航抽屉
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;
}
}
问题是我想在Allproducts活动中访问导航抽屉..这样可能吗?有人可以帮忙吗?
答案 0 :(得分:1)
点击按钮调用此代码。
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();