I am an android newbie and I am trying to create an Android App with three Activities: a Homescreen, a listview and a detailview.
I integrated J. Feinstein's Sliding Menu in my Homescreen and filled it with a ListView to display my different categories (Restaurants, Bars, Culture, whatever). When I click one of my List Items, the new Activity gets created and Pops up. However, I want the Activity to replace the old one while the SlidingMenu stays on top and then gently slides away. I saw this behaviour in the Example App but I cant quite find the bit of code that holds the answer to my question. Hope anyone can help :)
The sample app uses fragment transactions instead of starting new activities to change the content. As far as I know, that is the only way to do the two actions – close sliding menu and change content – simultaneously.
Related
I have fitted my app with a NavDrawer following the Android Material Design spec.
But initially the idea I had for my App's Navigation Drawer was different, I would like to maintain that design, but I need advice with the approach.
I have uploaded an image of what I would like to achieve.
http://i.stack.imgur.com/uzRBe.jpg
The user can click on button 2 and due to the nature of button 2, only that portion of the NavDrawer will slide out, or the user can slide the drawer out manually using a finger, and the drawer slides out and snaps to the edge of the screen just like the Android notification menu that u can slide from the top of your device.
Clicking on button four will slide the entire Group of buttons (due to the nature of content on button 4), button two would remain on the right if it were already there to start with.
Button 1 which would be the home button would check that all other buttons are in place (to the left) otherwise it draws them in then loads the home content into the main view.
I am not sure which way to approach this, using the Material Spec NavDrawer, or I custom design multiple linear layouts that follow the user's Xposition gestures.
Currently, I have a Material Spec NavDrawer, so the code is standard
Better to use the default Android Drawer Actvitity that comes with Android studio 2.0 and modify it.
it will save you allot of bugs
if you still want to create a cosutm one
you can either use what was suggested here >
http://simonvt.github.io/android-menudrawer/
or you can just choose one from this site >
https://android-arsenal.com/search?q=Drawer
it has some open library drawer helpers to help you write one.
i woul'd suggest against writing everything from scrach, it looks like allot of works and introduce allot of bugs, as to what needs to be on top of what every time, that you can fix by either using a library or taking the default one.
I need help finding an approach to build a certain kind of menu for an app.
Let's say I have a menu activity and 2 other activities. My menu activity consists of 2 options.
I want to drag the "buttons" (not sure if button is the correct name in this case) sideways and while dragging, the other activity's screen starts appearing from the side.
The thing is, depending on which button I'm dragging, different screens should appear, and I couldn't find anything similar to read about.
Does anybody recommend some topic to read that could help?
How can I manage the activities in this case?
I want to transform the upper left button that normally allows to open the Navigation Drawer to become a "Up" button (with the left arrow).
I looked everywhere but I couldn't find even a question where this problem is answered in a quick way.
Details:
I have a single Activity. The NavigationDrawer contains a list of elements. Let's call them Element1 and so on.
When I open the application I can see a "Home" Fragment that contains a sort of splash screen with some basic details of my application.
If I open the Drawer and select Element4 I switch the "Home" Fragment with the "Element4" Fragment. The icon at the top left should become the classic "Up" icon as intended in the Google developer site and allow me, touching it, to come back to the "Home" Fragment.
A simple example could be the NavigationDrawer application mockup created by Eclipse in its wizard. I want to modify it to make the 0 section the home section and if the 1 section its child.
Maybe if someone that knows how to do answer me it'll be a big help not only for me but for many other people.
Thanks
I am creating an app for Android 3.0+ that uses the action bar with tabs for navigation. I have 2 tabs that each load a ListFragment:
Tab 1 Tab2
A B
C D
Where A & C are list items in Tab 1 and B & D are list items in Tab 2.
Currently if you select Tab2 and then item B a new ListFragment is loaded on top of the current list fragment in Tab2. Pressing back takes you back to the original Tab2 contents. However if you don't press back and instead select Tab1 you see Tab1's contents on top of the new content you loaded in Tab 2. So I am guessing there is a better way of doing this. I wanted to use multiple fragments in each Tab to reduce the code complexity in each tab (for instance the onListItemSelected handling). Is there another way to do that without using multiple fragments? I am also trying to just save state but I am not sure how to tell the difference from when the user clicks back (then I would want to restore state) and the user has selected tab 1 and then selects tab 2 again (i would want to restore state).
Thanks
I am having similar struggles with the complexity of fragments and tabs on the Action bar. It seems to me that android for tablets is still very much in its infancy and there are various issues (like yours and the issues I'm having) that will be addressed in the coming months. For now, I think you just have to handle some of those complexities yourself instead of relying on the Android framework.
To answer your first question more directly, I think you need to step back and think out the functionality before diving into the code. I can give you a potential solution (keep track of your fragments manually in the activity and simply add and remove fragment as necessary via the ActionBar.TabListener interface.
Also, if you want the user to be switching from one fragment to another like you are suggesting, perhaps the back functionality shouldn't be used. What happens if the user clicks on the tabs 10 times in a row. Do you want the back button to take the user back through all of those events? I think the back button should only be used when the navigation system is very sequential and "back" is an easy concept. Check out all the Google apps that use tabs to see what I'm talking about.
i've got a tabbed layout, and on one of the tabs i have a search functionality. When the user makes a new search, i need to show the results. However, doing so involves starting another activity to handle the search results.
this causes the tabs at the bottom to disappear. The user can get the tabs back by clicking on the 'back' button. But somehow, in the context of my application this can be a bit counter-intuitive and seems to be break the common layout flow.
is there any way to prevent the tabs from disappearing when invoking the search from one of the tabs?
thanks for any help/suggestions.
as far as i can understand your problem, You are not using tabs then you are using buttons. see some tabhost tutorials on how to create a tabbed activity. what you are doing is launching a new activity instead of just switching a tab in the existing one.
Also the other things you can look for are activity groups.
Hope this helps you somehow.