I need to show Product list (perhaps some kind of ListView) and be able to display product details (could be more than 3/4 items and a place order button) when a product is clicked.
I have seen similar Accordion behavior but the expandable items are just single list items in my case I need to show multiple attributes of the product.
One way is to build a string combining all product attributes i need to display and bind to list. What are my other options?
I am relatively new to Android.
Note: I don't have enough reputation to upload an image/mockup.
Related
is there any similar source or tutorial that you recommend that is similar to this function of the widget?
The function is when we press the + button it will show the Category box again.
It's actually much easier than you think.
First, I'd suggest you to take a look at Flutter widget called ListViews (Flutter ListView, official documentation). They're amazing since, simply said, you can basically create a loop of widgets that show different data (and most of the time you'll show data from some kind of array that you'll access through the index of the current rendered item in the ListView).
How will you work with them? Basically, you're having a list of categories. Each category is having some data (for example, two texts and one boolean - availability toggle).
You can give an instruction to the ListView widget to render category widgets based on the list you'll maintain in your application flow. That list would contain list of categories that should be shown (so let's say, on the image you provided, we have only one category added).
When someone clicks on the "+", a new category item will be added to the list (most likely using the setState or other kind of logic that'll lead up to re-rendering) and after that, the ListView will detect a new item and show up a new widget that will be filled with the content from the newly inserted item at its index.
The functionality of my app can be modeled after something like wanelo.
The user will enter a search term for what they want to buy in one Activity. They will get presented with a list of items that match that search term. So, the ListView will contain Items. An Item has many attributes, the main ones being:
id - corresponds to the Item's id in a database
date_modified - timestamp to know whether the Item was updated
remote_directory - a URL to the base directory of the Item's assets like icon and other images. The URL is formatted like this: http://my.domain.com/items/a1bc234d/ where a1bc234d is randomly generated, seeded by date_modified.
remote_dir_name - a substring of remote_directory. From the example above, this value would be a1bc234d.
From the list of search results, the user can mark an item to be viewed later. This will trigger a couple of things:
First, I want to ad the Item to a different ListView that represents the Items the user has "downloaded".
Then, I want to actually download of all of the Item's data: description, all assets in remote_directory. These things get stored my app's internal storage in folders remote_dir_name: /data/data/my.app.package.name/files/a1bc234d/.
These "downloaded" items are meant to be viewable in offline mode.
This "downloaded" ListView corresponds to a different Activity and will have list items that show a progress bar of the download status for an Item. Also, this ListView should be editable: use should be able to delete and re-order the Items in the list.
Finally, the "downloaded" ListView needs to be persistent. It should preserve order. The ListView of search results need not persist.
I'm having a lot of trouble figuring out how to store the list of Items getting downloaded. The "download" ListView needs to know when to update a list item's progress bar if it's getting downloaded. I think it's a little overkill to store the Items in a database because I'll be constantly updating a row's column until the download finishes. How should I pass this download status information between these two ListViews?
I am not entirely sure I am grasping the whole picture here, but it seems to me that you need two ArrayList fields.
List<Item> downloadedItems = new ArrayList<Item>;
List<Item> searchItems = new ArrayList<Item>;
then what you need to do is create your own custom ListAdapter for the DownloadListView and create your own custom download_item.xml that you will inflate inside of the ListAdapter. In your case it sounds like this download_item.xml will consist of a textview, and a progressbar, and will need the containing (or top layer) layout set to wrap content.
Now in the on click listener for the SearchListView set it so that it will call a function that will take the item that was tapped and add it to the downloadedItems ArrayList and start the download, as well as refresh the listadapter dataset so it knows to update the items in the list.
The download should be in a AsyncTask, and you will want to use the #Override publishProgress() portion of this, so that you can update the status of the download bar.
forgive me for any mis sights or mistakes, I just woke up.
I'm developing an Android App and I need to display some data in a scrollable Listview.
I will extract some strings from objects that I right now have stored in linked lists (until i come up with a better solution).
I want to display a view that looks almost like the contacts app. A list with a small picture to the left and a larger text to the right of the picture with a smaller text the bigger one. When I click on one of the items it should open a new activity.
How do I create the view? If I adds an object in the linked list it should appear in the list.
I have checked some sample code, but they all uses Arrayadapter and I dont understand how I am supposed to do.
Check this article about Adapters: http://www.vogella.com/articles/AndroidListView/article.html
If you want to add new objects in ListVew use:
adapter.notifyDataSetChenged();
Check the libraries in this question, you have what you need there:
Lazy load of images in ListView
I am programming for android 4.0
I would like to create a listFragment divided in 2 sections. This means i want it to be 1 long scrollable list but with a divider between the online items and the offline items. And of course when one item comes online it should jump upwards + the other way around.
All the items are clickable but the divider shouldn't be (and preferably have a differend colour)
How can i do this or is this even possible?
Ok so , a fragment is basically an activity and you can treat it like an activity, in your case you should extend ListFragment (which will act like a ListActivity in a sense).
now, a List Adapter (which populate a list) in its default way will only allow you to display a list in its most simple form so in order to achieve what you want (a list that deals certain list items differently) you will need to write your own Adapter.
its best if you get the data in the order you want them to be displayed so if you can sort the "online" items from the "offline" items straight from your data source you should query it this way. so now the only thing you need to add is a separator between them and you can do it by finding the first "offline" item and inflating a separator above it (this is done inside your adapter).
each task by its own has dozens of tutorials and Q&As around the web and on StackOverflow.
hope it helps and i'm here if you need more help.
I have a program that I would like to display the name and house number of a group of people. This information is being picked up from a web server and is all sorted (xml format) but I wanted it to be displayed in a ListView with the two different pieces of information in a single list item. When getting the information from the server there may be 3 people there may be 30 so a list view where it extends with the amount of information there is is essential. Any ideas?
You would create a ListView and set your own customized ListAdapter that will display the two pieces of information you need in a single list item
Consider using an ExpandableListView it allows you to have custom "sub-data" under each list item.