I have made an app with one activity which uses a navigation drawer to open a number of different fragments. I have the actionbar drawertoggle, but it is not very visible. If I place a button in the onCreateView in my main fragment(the fragment that appears when my app first starts up), how can I get it to open the navigation drawer controlled by my activity?
This seems to work. The answer is much simpler than I thought it would be.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View fragView = inflater.inflate(R.layout.mainmenu, container, false);
button1 = (Button) fragView.findViewById(R.id.button1);
mDrawerLayout = (DrawerLayout)getActivity().findViewById(R.id.drawer_layout);
mDrawerList = (ListView)getActivity().findViewById(R.id.left_drawer);
button1.setOnClickListener(this);
return fragView;
}
@Override
public void onClick(View v) {
mDrawerLayout.openDrawer(mDrawerList);
}
Thank you for your answers.
mDrawerLayout.isDrawerOpen(drawerView)
instead of flag – Toilsome