I know EXACTLY what I want to do, but am new to android programming. I have gone through countless tutorials and searched everywhere, but cannot find any code examples of how to use multiple listviews (or other method, if there's a better way) in Navigation Drawer to achieve a true multi-level drill-down menu. I'm talking 4 or maybe even 5 levels of hierarchy. Expandable listview will NOT work for me. The BEST explanation I can find is the "Dropbox" example located here: http://www.androidpatterns.com/uap_pattern/drill-down-navigation
Let's assume this is for a product catalog. So listview #1 would have options like Computers, Appliances, Video, Audio. Listview #2 would re-populate the NavDrawer list with options like Stereos, Speakers, Cables (assuming they select Audio), Listview #3 would re-populate list with Sony, Yamaha, Etc. (assuming they select Stereos), and the final listview #4 would list all Sony stereos. When they make their selection, it would query the database and display the fragment view of that particular stereo.
I think I can handle all the database code. What's really holding me up is simply the functionality of the navigation. I am a very visual learner, so any actual code examples or tutorials you can point me to would be invaluable. Thank you in advance for any help! :)
I would implement it with Fragments. For every level in your hierarchy you create a ListFragment and if a user clicks on an item in the list you perform a FragmentTransaction and replace the current Fragment with the next one. I assume you know how to implement a ListFragment, if not I can explain it to you. I'm not sure what code samples to give you aside from just posting a completely implemented ListFragment as this is not really a very specific question. Perhaps I can help you further if you explain what you have tried so far or if you post some relevant code.
Related
this might be a duplicate question but I'm wondering how to use the two-line list from "material design" on a recycler view. I can't figure it out, and I can't find anything on Youtube and Stackoverflow after searching for about an hour.
I want to create something like the picture below.
This image is directly from the website itself: https://material.io/components/lists
Thanks!
Well, in order to do so, it would suffice to use android.R.layout.simple_list_item_2 as the row layout in your Adapter. Although it won't have the overflow menu icon. I don't know if you are trying to replicate that exact same list you posted.
But honestly, I don't know what's your Android experience. Do you have a working understanding of RecyclerViews and Adapters?
The link you provided shows Material Design guidelines. It doesn't necessarily mean that those lists and functionalities are ready to use with any basic Adapter you implement. For complex rows, you need to provide the layout, as well as implement functionality to user-initiated events such as click listeners, swipes, drags, etc.
For me, codelabs are always a good place to start with some hands-on exercise.
RecyclerView codelab:
https://developer.android.com/codelabs/kotlin-android-training-recyclerview-fundamentals?index=..%2F..android-kotlin-fundamentals&authuser=1#0
Maybe someone knows/or found somewhere how to make this kind of list on android using kotlin?
https://cdn.dribbble.com/users/418188/screenshots/2182940/art_gallery_app.gif
I think it's similar to Material desgn:
https://material.io/design/components/lists.html#behavior
but I couldn't find anywhere is it cards layout or some expandable list view. So maybe someone experienced could tell me from where I should start to make list like in the first link?
Moreover for such transitions is it better to use Fragments or Activities?
I have a question related to Material Design introduced in Android 5. I'm very new with UX interfaces. Now I'm trying to implement simple music player with fragment for choosing songs from storage. Actually, that fragment contains RecyclerView. But RecyclerView doesn't show any element (it contains views with one TextView), even simple "..". I checked it with log-tracking and found that function "onBindViewHolder" was called correctly. To be honest, I have no idea what is wrong with my code. Obviously, I provide link to my project: UX
I will be gratefull for any suggestion, advice or may be pointer to the mistake.
I'm new to Android programming and I'm working on my first application "FunFacts" where
there should be more than 100 cool things to learn about nature, science etc.
My question is: How can I switch from one page to another using two buttons "left" and "right"? which method should I use? I don't think that a horizontal scrollview is the solution.
So if I have 2 different layouts, page one and page two, how can I switch from one to other in my application?
Thank you!
It sounds like you might want a ViewPager. Below is a link to the Android tutorial. This creates a slideshow type effect which sounds like what you're going for. You said you will have different layouts which this will use one layout but you can customize the content and I would think you would want one so it all looks relatively the same
Docs
Update
No, you don't have to create 100 layouts or activities. Just one of each. Following will be a link to a post that explains it a little better. That post explains how it is like a listview in that you add the different pages to your view adapter as you would with a list. You can use the same layout for all and just add new data to it (like a list). Probably store them in an ArrayList or possibly a DB if you have that many and want to have a lot of data attached to them. I hope this makes sense and helps a little. I would suggest starting one with just a couple pages to see how it works, following these examples, and if you get stuck then post a more specific question as to what you can't get to work.
Link
I am making my first android application with the ActionBarSherlock.
The application will always have an action bar consisting of 3 tabs (first tab selected by default).
The app could be extended for use with a tablet.
I have been searching the web, and following the android development guides, however I am finding a few things confusing.
The first tab screen will be a list view with a list of items, onitemselected should send the user to a screen which features more details about that item.
When should I use a fragment? Should each tab be a fragment?
Or, should each tab call a new activity, which consists of fragments?
And, if using fragments, should I place them in different classes, or embed them within an activity??
Appreciate any help, thanks.
you should probably read these two links first.
http://android-developers.blogspot.com/2011/09/preparing-for-handsets.html
http://android-developers.blogspot.com/2011/02/android-30-fragments-api.html
If you plan to make an app that work on both phone and tablet. It is a good idea to use a fragment, and then use a shell activity to wrap that fragment.
My experience with Fragments is mostly on ViewPager, so I am not entirely sure if it applies here.
In Android, you should use Fragments as much as possible. As a general rule of thumb, imagine you are translating the UI from phones to tablets, elements that can stay together in the same configuration should be a Fragment.
There is a Fragment subclass called ListFragment, so you might want to look into that for your first tab. (ListFragment is for Fragment like ListActivity is for Activity)
There is also a tutorial I found to deal with fragments. Did not really look into it but I hope it helps.
http://android.codeandmagic.org/2011/07/android-tabs-with-fragments/
As for ActionBar / ActionBarSherlock, I have absolutely no experience withit so someone might want to add to that.