0

I have an activity with a left pane and I need to change input fields when a different item is selected from the left pane. I tried by adding a new activity but when the new activity show up the left pane disappears and the only way to get it back is by hitting the back button and I don´t want that; the left pane must hide but must remain to select a new activity and let the user jump from one activity to any other that he choose.

How I cant get that?

I read also about something called fragments but since I'm new on this it looks a bit more complex.

D. PRAKASH
  • 305
  • 1
  • 12
E_Blue
  • 1,021
  • 1
  • 20
  • 45
  • did you try making the "with left panel" activity a base activity? Therefore all your new activities will have a left panel. – fangzhzh Jun 24 '19 at 01:42
  • @fangzhzh I created the App by chossing "Navigation Drawer Activity" in Android Studio. It's Not the same? – E_Blue Jun 24 '19 at 01:58
  • 1
    https://stackoverflow.com/a/19451842/415673 it briefs both the fragment and the base activity solutions – fangzhzh Jun 24 '19 at 02:02

3 Answers3

1

I would review the documentation on Navigation, particularly on using a NavigationDrawer.

Hope that helps!

dominicoder
  • 9,338
  • 1
  • 26
  • 32
1

Refer to below Google Navigation Drawer Sample where you could find the correct way of implementing it.

https://github.com/googlesamples/android-NavigationDrawer

In addition I would recommend exploring bottom navigation, which is like the new navigation trends user enjoys. Here is a code lab for it: https://codelabs.developers.google.com/codelabs/android-navigation/#0

To choose which component to use for your app follow this material design guideline: https://material.io/design/navigation/understanding-navigation.html#lateral-navigation

Tip: To Speed up your development you can directly add Navigation Drawer Activity that will help you save a lot of time by adding the base code. Just add new Navigation Drawer activity by right clicking the package.

enter image description here

TheAnkush
  • 885
  • 7
  • 10
  • Did you know if exist a compatibility table of the different objects like Navigation Drawer, Bottom Navigation, etc? I need backward compatibility with Android v5 devices. – E_Blue Jun 24 '19 at 03:05
  • 1
    @E_Blue - Both are backwards compatible for Android v5 devices (API 21). You should also check out this for better navigation implementation if you are starting by scratch https://material.io/design/navigation/understanding-navigation.html#lateral-navigation – TheAnkush Jun 24 '19 at 03:24
  • @E_Blue: I have updated my answer, hope it helps you to make better navigation. – TheAnkush Jun 24 '19 at 03:32
  • Yes, I'm starting from the scratch, the previous programmer was an external programmer and he lost the source code; so now I'm trying to recreate the app an testing different ways to implement it. – E_Blue Jun 24 '19 at 04:28
0

Hmm. Yes using fragments is the best solution. But you can also play around with hiding and showing views.