I am newbie Android 'developer'. I want to launch my application with two Activities: ListView (with optional slide up panel) and Navigation Drawer. I began my project from taking Navigation Drawer Activity and I modified it. Now, I want to add ListView but how to do it? I have tried to add this before android.support.design.widget.NavigationView in activity_main.xml but It doesn't work. Maybe should I add a new Activity in function onCreate in MainActivity class? Any ideas?
Thanks
Related
I watched some videos for navigation drawer in android studio .. some people started from an empty activity and other used Navigation Drawer Activity from the Starter ..
So what's the difference ?
And what activity i have to implement ?
(my first activity is splash screen and all others activity will be added as new activity, btw I'm doing a football application so advice me <3)
Android studio provides you some templates as starting point with boilerplate code to get you started quickly on your project.
If you select DrawerActivity, It will create one of the templates, you can use which has all the boilerplate implementation for the Drawer Menu.
On the other hand, if you select EmptyActivity, It will just an create an activity with nothing in it (mostly blank or HelloWorld TextView in it, depending on studio versions).
By the way, you can always create an EmptyActivity and add things gradually like drawermenu etc in it if you prefer this way.
Empty activity : It has just the white screen and nothing else.
NavigationDrawer activity : Empty screen integrated with Navigation Drawer
I am new in Android,
using Android Studio.
in my project I had made multiple activities.
now I want to make one navigation drawer for all the activities.
I am not want to use Fragments.
thanks in advance.
If you don't wanted to use fragments then the best method is to create a BaseActivity which extends Activity (or AppCompactActivity). Inside onCreate method do all the codings for navigation drawer.
Now for Which ever activity, navigation drawer is required you can extend the BaseActivity.
eg:
public class MainActivity extends BaseActivity{
......
}
Don't forget to include navigation drawer xml codes inside the layout files of different activities.
also you can use include for reusing drawer layout.
I'm working on my App about 6 Months.
I don't know if I misread it but, is it possible to create and add a Navigation Drawer when I have different Activities?
How my App works:
SplashScreen -> LogInScreen -> Activity 1(ListView) -> Activity 2 (after click on ListView item) -> ... and so on.
Is it possible to add now a Navigation Drawer? I read something that you can add a Navigation Drawer only if you don't switch between Activities is that right?
I want a Navigation that looks on every Activity different. Is it possible or it can only have one layout?
I hope my problem is clearly explained.
Kind Regards
All your other Activities should extend The MainActivity which contains the navigationView .
helphuf links : Same Navigation Drawer in different Activities , Android: Navigation-Drawer on all activities
Yes, it is possible. I suggest following option to use navigation drawer in all Activities of App.
You have a two option :
1) Use Fragment instead of Activity and put navigation drawer to First Activity.
for Example : http://www.androidhive.info/2013/11/android-sliding-menu-using-navigation-drawer/
2) Create One layout for navigation-drawer and include it to all layout of your Activities using "" tag in xml Like this link : navigation drawer layout with include layout
for Example : Same Navigation Drawer in different Activities
I am developing an Android project with Android Studio.
I would like to have the menu is always accessible in every view like Google Play Store (the Sidebar) and App Store (the Bottom selection bar).
I am thinking to do it in two ways:
Make my app have only one activity with Navigation Drawer, all the other views are above this activity using fragments.
Recreate the sidebar or bottom selection bar every time I switch to another activity.
Both of these two ways are very complex and cost a lot. Do you have some better ways?
PS: If not, could you suggest me some links about how to implement these two methods?
Thanks a lot.
you can create a MasterActivity that extend Activity and contain your sidebar. other Activity can extend from your MasterActivity by this way you can access your sidebar on each activity.
I think you should use the default navigation drawer and default action bar.
If you are using the Android Studio then
right click on your package and go to New/Activity/Navigation Drawer Activity.
That will create navigation drawer fragment and activity automatically.
But If you are using Eclipse then these links will be useful for you.Navigation Drawer
Action Bar
you can use include tag in other layout activity and call Navigation Drawer:
<include
android:id="#+id/nDrawer"
layout="#layout/your_NavigationDrawerLayoutName"/>
I have made a nice app with a whole bunch of activities , then i needed a navigation drawer and found out that you need to have only one activity for the whole app and the individual different screens should be fragments that are inserted at runtime.
my question is :
How to convert the entire app to use fragments instead of activities ? (eg: how to preserve activity hierarchy , show a main activity when the user opens the app , different actionbar for each screen , etc...)
There is no magic converter, you need to convert manually each activity to be extended from Fragment
and add few must methods like onCreateView for the fragment instead of SetContentView of activity.
Regarding the actionbars, it sits on the Main Activity so you need to create callback events from each fragment to the main activity in order to control the action bar.
Navigation drawer has nothing related to fragments.
If you wish you can put it into activities also.
What I created was a BaseActivity with layout having navigation drawer and all other activities extend BaseActivity so that each of your activity will have drawer. Only you need to change content page for particular activity.
happy coding.