I have a custom Listview in my android app and on list item click, I'm able to navigate to other activity, which shows all the details about list item !! Now my question is, I want to navigate to next/previous listitem's details through second activity.. how can i do this.??
I'm new to android and stackoverflow as well..
Thanks in advance !
I guess this is more of a design question, so i'll answer that way -
Your best bet will be to use something like a ViewPager in the new activity, which receives the selected item position and displays it with underlying adapter having the same items from the previous activity. using the ViewPager the user can swipe left and right between items.
For a good example on this usage, you might want to take a look at "Google Reader" on Play Store which has this exact same design pattern.
Related
I'm new to android development, and I have doubts about working with fragments.
I have to build an App that runs 2 ListViews on the same screen, but the list on the right depends on what I select in the list on the left. I've looked through all the tutorials and samples about the working with Fragments, and I haven't found a way to do that succesfully.
Hey refer this link and follow the example explained there. In the example given you have listfragment and when clicked on an Item, details will be changed. So You implement another listfragment which will display items upon selection of first listview instead of Details.
I am making an application and I can't figure out what's best to do.
I have a long list of tableRows. About 200 of them. They are different
models of a specific product. Each row, when clicked, should show a
screen with that item's specs for the user to read.
Here are my options, I would need help and guidance on how to do each one of these as I am a beginner (but I'm getting more advanced)
First Approach
Create an activity for each and every item. The user will click the row and then they will have to press back to get back to the list. (I know how to do this. I'm fine with this)
Second Approach
I read about horizontal page swiping. Similar to the Play Store. I would prefer this option, but would I be safer sticking to lots of activities?
When the user clicks a row, it would bring them to the item spec and they will be able to swipe left and right between all the items. Pressing back will bring them back to the list.
(This is the one I need full step-by-step guidance with, so I can learn for the future, thanks)
Does anyone have any other suggestions how I would handle this amount of data?
Thanks
You have a long list of items. That suggests you use a ListActivity to show the items. If the items have similarities, use one view to show them and one Activity to show details. If the items are totally different, use different layouts to inflate in getView and different activities. Having the items in one list suggests, however, that there are similarities and it's best to use one layout in the listview and one activity for details.
Alternatively, you can group your items according to similarity in the way you show them. You may end up with ten different views to use in the listview, and ten different activities.
I would like to design an item like this that opens a subset of other items when clicked, I have only seen it in other applications I've used, and I can't find any resources on how to create it. Does anyone know how to?
Thanks.
Its not clear if you want to created Nested listviews that look like this
-Item1
-Item2
---Item2A
---Item2B
-Item3
or if you want to open a completely new list when the user clicks on an item.
If you want to use a nested listview look at this question: android nested listview
And if you want to open a new activity, then create a 2nd activity with a listview and open that on an item click
Perhaps you should try to have a look at the ExpandableListView.
Documentation is available from here:
http://developer.android.com/reference/android/widget/ExpandableListView.html
If you wanted to add a ListView that opens another list, you can do it in several ways. I've successfully done it by adding an OnItemClickListener to the ListView and then simply load a new set of data in the ListView and update it using invalidate() or by setting a new Adapter.
You could even add some cool transitions or animations, and create a listener for when the animation is completed. Lots of cool ideas :-)
What is the correct way of showing a new View with more detailed information from a ListView in Android? It's a topic that I can't find a solid answer for in either of these Android books.
For example a list of contact names, one is selected and a view shows their full details.
Do I launch a new activity for this or use a ViewFlipper?
Your approach is right. It's the recommended one.
When designing an activity, it's suggested to use this paradigm:
One activity = one thing to do.
Viewing the list
Viewing the details
On the Notepad tutorial app, a new activity is launched to view the details of a list item.
Anyway, the ViewFlipper is another possible approach that keeps all the content in a single activity. This approach is suitable if you manage the Back key correctly.
I have an issues, I want to show 20 items in the list.
But there is a catch: if the user scrolls down to the bottom of the list, there will be an item that says: "Show more items", and when the users click on it, more items will be added to the list.
My question is how is poosible to have a last item, that has a different style and looks different: and does different things,(I think this is used in QuickSearchbox)
If you still want a clickable item rather than an infinitely scrolling list you can try using ListView#addFooterView to add your "Show more items" item. This lets you add a view as the last item in a list. Make sure you call it before calling setAdapter.
I would recommend you commonsware's cwac-endless.
cwac-endless: Provides the
EndlessAdapter, a wrapper for an
existing ListAdapter that adds
"endless list" capability. When the
user scrolls to the bottom of the
list, if there is more data for this
list to be retrieved, your code gets
invoked in a background thread to
fetch the new rows, which then get
seamlessly attached to the bottom of
the list.
While commonware has some awesome stuff. His endless lib may not be what you want. What you probably want is a footer. On your ListView, before you set your adapter, call addFooterView. Note that if you do that, the adapter you get from ListView.getAdapter will not be the same as what you passed to ListView.setAdapter.
Edit
Speaking of commonware, he sells a few books on his site. Buy them. They are the best $40 you will spend on your android education.
In the layout below the listview you can put a linear layout with "Clear" and "Get More Results" buttons. Not exactly what you are asking but it can achieve the same result.