I have a requirement to use NavigationnDrawer in my project.
Question: considering my app has multiple Activities (some has master/detail fragments)
The master/detail fragment would have single container layout for tablets and large width devices and 2 different layouts on smaller width for master & detail views.
What can be right direction to proceed (1) or (2) or any different advice which makes more sense?
Every activity has a NavigationDrawer and it's layout rendered using setContentView(layourID) in OnCreate().
All activities extends a Base Activity which uses NavigationDrawer.
If answer is (2) please provide some more useful advice. And if it's something else , please do share .
I think this tutorial may help you. http://www.youtube.com/watch?v=K8hSIP2ha-g and also refer this http://www.tutecentral.com/android-custom-navigation-drawer/
Related
I m new to Android development and stuck with design. I d like to design a single activity application with multiple fragments. But whatever I consider, I m stuck with design.
I first considered fragments as components or widgets that I could organize where I wanted on my screen. But a single activity has only one xml view layout and can not find a solution.
Here is what I want.
UI design
The problems are the following.
The layout choice: I need a layout for full screen fragment screen 1 but another splitted one for other screens.
The keyboard: if I do a fullscreen fragment layout for all my screens with a (game-keyboard) fragment and (dico-keyboard) fragment, how do I remove the keyboard in dico fragment on tablets ? And can I share keyboard code between both fragments ?
I saw that calling setContentView during runtime is kinda annoying as you have to reassign your variables and is not suitable.
All the applications I find are fullscreen single fragment on layout allowing libs like ViewPager. I can not find an example of composed screen with fragment components.
What layout would you chose, with what kind of fragments ?
Or do you know a library that allow composing fragments as widgets on screen ?
Thanks for your help.
Welcome to Android. Buckle up, it's going to be a bumpy ride.
First, you should spend some quality time with the Android Developer Guides.
Developer Guides | Android Developers
The insight for your particular challenge is that layouts are resources, and and you can have a layout resource that changes based on the configuration.
So for example, you could have a resource like layout_main with one XML file for small devices and a different XML file for large devices.
App resources overview | Android Developers
Create alternate layouts | Support different screen sizes | Android Developers
You can arrange fragments on a layout using the Android Studio layout designer.
You can add Fragments and navigate.
First of all yu need a navigation: In the left hand side on Android Studio you can find the Resource Manager Then click to Navigation then click to + and choose the Navigation resource file
After this you can add fragment to the navigation:
New Destination (green +) (Don't forget to give name to your fragments).
After this you can add the navigation to your activity's xml. You should use the app:menu=”#menu/bottom_nav_menu” code in your xml
Here a video about the process:
https://www.youtube.com/watch?v=Chso6xrJ6aU
I have an Android app with two classes:
-MainActivity
-SecondActivity
I have also two layouts for these classes (they are pretty similar).
I want to switch between these activities by 'shifting' to the right or to the left.
All materials I find are about switching by button.
Anyone would recommend using Fragments and ViewPager instead of Activity since you want sliding action and make use of the Android TabLayout.
Here is a tutorial that you can draw a basic idea from.
I'm building an Android App which has a complex screen with lots of logic.
It currently contains a listview, tabs, search box, and a panel for updating user stuff.
The probem is that the mainactivity code file became very big, although I'm seperating things to different layers, because there's a lot of UI components which affect things in the screen.
I'm trying to seperate it to several files but I don't seem to do it right.
As much as I understood Fragments is not what I need here. Are there any other ways?
Just need some directions please.
I'm asking mostly about the code, not the layout (Although I don't care changing the layout too).
Currently it's 616 lines and the biggest problem is that we are a team and the maintenance became hell...
Create utility class and put your listeners and adapters there. Use main activity only to initialise view instances and setting listeners and adapters.
Although 616 is not a particularly big file you could use Fragments as they just add another layer of abstraction. They also have a similar lifecycle to activities.
This tutorial shows how to add fragments to tabs
http://developer.android.com/training/implementing-navigation/lateral.html
You can create a base class put all the initializations and listerners there.
Likewise for function to be implemented later create a template in base class and override it in main activity. It works !
Is it possible? supported?
I want to make an app that hosts widgets in fragments, I know how to do it on activity but don't know if it works with fragments.
Im sure you mean AppWidgets, so take a look at this
https://github.com/DagW/FragmentHomescreen
It contains a complete example project for adding widgets to fragments in a viewpager.
It also contains code for adding appwidgets programatically.
I'm developing an application for android that is supposed to have three tabs that shows three different listviews. It should look pretty much like this video example:
http://www.androidhive.info/2012/05/android-combining-tab-layout-and-list-view/
The problem i have is that TabActivity is deprecated and i can't found any good tutorials for the Fragment view (which I think is the one to replace TabView). Anyone know how to combine these two views?
You might want to look into ActionBar and Fragments. Maybe the following link could help you out? http://www.lucazanini.eu/2012/android/tab-layout-in-android-with-actionbar-and-fragment/?lang=en