1

I have problem when clicking on a drawer it will navigate to an activity.

            if ( (listDataChild.get(listDataHeader.get(groupPosition)).get(childPosition).equals("Fuel"))) {

                Intent intent = new Intent(MainActivity.this, Fuel_1.class);
                startActivity(intent);

But when it go the activity , i dont see the drawer . I need to press back then it will see the drawer. How to enable the drawer in activity?

Rahul Singh Chandrabhan
  • 2,531
  • 5
  • 22
  • 33
  • Show a detailed code of how you are doing it. – Clement Osei Tano Nov 13 '18 at 08:34
  • @CoolGuyCG basically i want to display navigation drawer in activity. – Muhammad Zawawi Nov 13 '18 at 09:20
  • But a lot can still go wrong, so post the code of how you are doing it, then we can see what might be wrong and what needs to be added. – Clement Osei Tano Nov 13 '18 at 09:30
  • Navigation drawers are attached to activities. The problem you are facing is that when you move to this new activity, the navigation drawer is not attached to the new activity but the previous activity, that's why you are not seeing it in the new activity. You may want to use fragments or add the navigation drawer to the new activity – orimdominic Nov 13 '18 at 10:19
  • @OrimDominic actually I already use fragment and it is working but unfortunately I have a problem with fragment then want to use activity. Can we simply extends the navigation drawer?Because when if we use interface ,i need to add all the method of navigation drawer in the activity and it make the code too long. – Muhammad Zawawi Nov 13 '18 at 10:22
  • @MuhammadZawawi yes you can. Check this question [Same Navigation Drawer in different Activities](https://stackoverflow.com/questions/19451715/same-navigation-drawer-in-different-activities) – orimdominic Nov 13 '18 at 10:27

1 Answers1

0

I don't fully understand your statement. It is required that if you click on any object in your drawer to take you to an activity specified according to your code. But I guess you want to go to the activity while still displaying your navigation bar? or probably for you to go back to your drawer with a back button from your present activity?. If the latter is the case you can do that in your manifest. just edit your present activity in your manifest like this: <activity android:name="com.example.myfirstapp.DisplayMessageActivity" android:label="@string/title_activity_display_message" android:parentActivityName="com.example.myfirstapp.MainActivity" > name: this should be the name of your present activity. label: title of your activity. parentActivityName: this is your Main Activity. the place you want to go back to when you press the back icon. I hope you understand this

taiwo sunday
  • 33
  • 1
  • 8