I didn't use parse query adapter, instead I made a custom adapter and passed all the text and images in that but Parse only loads 100 items. Can anyone tell me how to get to the next page of the database without using the parse query adapter?
This is a well known problem, the default limit is 100, you should use (saying that you have a query which is a ParseQuery object), you need to call the query.setLimit(int N) where N represents the number of results that you want returned .
Related
I am fetching a list of dogs from an endpoint. Some of the attributes of the dog, color for example, are identified by id. The id's and colors corresponding to the id were all saved in a database when the app is opened. I am using MVVM architecture and assume that the model is consuming the response data correctly.
In the main screen of the app, I have a recyclerView that will populate with a list of dogs. when I fetch the list of dogs, I am returned the id of the dog's color as part of the dog object. The user isn't going want to see the id of the color, but the actual string value of the color corresponding to that id. I need to query the database with that id to get back the string value of the color to display to the UI.
My question is how would I go about doing this? The recyclerView adapter would be where the UI is updated, and I would need the position of the dog to know what color Id I am fetching, but I can't run that query from the adapter as it would lock up the main thread. I thought to create a function in the view model that would update that particular list item, but I think I would still need the position from the adapter. I'm not really sure how to proceed...
I hope my question isn't too confusing, I had a hard time figuring out how to ask! Thanks for your time!
You want to build proper query in your DAO and "join" values from another table, depending on color_id.
You are not allowed to do any queries at adapter level. Data passed to adapter must contain everything you need.
Joins and mappings are described here: https://developer.android.com/training/data-storage/room/accessing-data
is it possible for a Spinner to return multiple values or class object on selected?
For example I have a Spinner of Laptop models. When selected I want it to return LaptopSpecs object that contains size, weight, processor, etc. Then use it to display the information in the view below it.
Thanks
Sorry, there is no multi-select Spinner. You are welcome to use a multi-select list AlertDialog to allow the user to make their selection(s), but you will need to decide for yourself how you want to render those selection(s) when the dialog is not on the screen.
It depends on how you are populating your spinner.
If you are pulling the data from a database in a cursor, what you are trying to do is easy.
As a matter of fact, using a database, there's a couple ways you can do it:
1) You simply pull all the necessary data you need to create the object into your cursor (kinda heavy load on the front end), and when a selection is made (fromthe single bit of data displayed in the spinner), you use the cursor position reference in the onItemSlected method to pull the related data from the cursor and pack it into your object.
2) You pull only the piece of data to display in the spinner and when a selection is made, use the database row id in the onItemSelected method to fetch the rest of the data for your object from the database.
What I want to do:
Display a list of items
The actual data is coming from an external source and can change
Each item can have several "columns". E.g. "type", "content", "date"
The list should e.g. be sortable by "type" and "date".
I thought I might be able to get the desired functionality using a ListView (but maybe also this is a very bad choice?). I have read some stuff about them, but still have some questions. I know that the ListView Displays data which is managed by an Adapter. If I have an ArrayAdapter, does the Listview always display the items in the order of the underlying Array in the Adapter? So to implement sorting, I would have to somehow change the Array in the Adapter? I have read, that you can use SimpleAdapter to have several properties in a row, but the data SimpleAdapter uses seems to be static. How can I achieve that?
Thanks in advance!
Yes, ListView will represent depending on how your ArrayList or Vector([]) is sorted. Now, if you want to have several properties for each row, I would recommend that you create an Object of your choice, for instance: class Person which takes name, age, address etc etc.
Then create a list which takes Person objects. Then in your getView of your ArrayAdapter that you will override, you can call Person person = getItem(position); and now you have a hold of that object in that specific row (position), and can do whatever you want with that Person object.
Create your own adapter, and in getView() return view that matches your position. For instance if you got data like this:
id name
0 ccc
1 bbb
2 aaa
then when you sort by id and listview wants row at position 1, you return 1 bbb. But if you sort by name ascending, and list wants row #2, then you return 0 ccc. Of course you need to maintain the "mapping", but that's rather trivial.
I have a ListView which uses cursor adapter to show the records from database. When a new records is inserted in database ,it works great and shows that entry on top of ListView on requery.
Now I am facing problem when User scroll down the List, background thread call web service and brings old data. In this case when it does requery, old data is also getting appended on top of list which should append old data at the end of list.
What should i need to do differently, to add old data at the end of List rather than top ? do i need to change method of insertion when I am getting this old data ?
I think you need to store a date field in your bd table and make an ORDER BY in the query....
Friends,
I need to fetch data from SQlite Db and set it on List View,it fetches data has well but the view showing on screen being empty,anybody help me to get the content to visible.
For simple String values use an ArrayAdapter, for custom UI on the lists, create your own Adapter and override the getView method.