Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show/Hide DrawerLayout depends on current fragment

I have an Activity class that have a DrawerLayout. That layout shows a list in Drawer and let user to switch between fragments. In these Fragments, there are some URLs and when user clicsk on that, a WebviewFragment would be shown. However, I don't want to show the DrawerLayout in the WebViewFragment. Instead, I would prefer user would being redirected to previous Fragment.

Is there any way for me to show/hide the DrawerLayout depends on what the current Fragment is? I try to call mDrawerLayout.setVisibility(View.GONE), but it seems that it is not complete. At least the ActionBar icon is still the drawer icon.

like image 707
Bear Avatar asked Aug 10 '13 04:08

Bear


1 Answers

Why not open a new Activity that has only a WebView as its content instead? Then the user will have to press the back button to go back to the Activity with the DrawerLayout, and then there will be no problems.

Alternatively, you don't have to have such an activity yourself, you can let Android find a browser for them to open instead using this code:

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("HTTP_URL_GOES_HERE"));
startActivity(intent);
like image 155
Karakuri Avatar answered Nov 07 '22 13:11

Karakuri