问题
I'm trying to make a new android project in which I collect my data from an online JSON file. If I look on the internet, I can see a lot of examples where they are storing the collected data in a MatrixCursor. Personally, I think it's much easier (and much shorter/faster) to store all the data in a list in a model class. Is there a good reason why they are not using Lists instead of MatrixCursor, or what are the differences between them ?
回答1:
I also prefer to have model classes that can be created from JSON data along with a custom ListAdapter
for those classes.
However, there are components such as SearchView
that specifically require a CursorAdapter
i.e. for search suggestions. In those cases. it's easier to put the data into a cursor like a MatrixCursor
, pass that to a SimpleCursorAdapter
and be done with it.
来源:https://stackoverflow.com/questions/30366972/difference-between-list-and-matrixcursor-android