开发者

Android sorted listview question

I am having a bit of trouble with android. I have a sorted listview of items retrieved from a database.

This 开发者_如何学JAVAis where I run into the problem. How do you get the actual database row id of the item based upon the listview? I can't use the position of the list view due to it being sorted. Is there a way to retrieve it from CursorAdapter?

Thank you,


Have you tried

Adapter.getItemId(int position);

See the description in the Android docs.


One thing you can do is to make your database query to order the results by your sort criteria, so when you get the position of your listview item, you can then lookup your Cursor at that same position and retrieve the correct row id.

Another way, which may help, but I haven't actually tried is to somehow map the row id of the item to the listview item's "tag" property. http://developer.android.com/reference/android/view/View.html#Tags

I hope this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜