如何创建与Android的光标数据的列表阵列 [英] How can I create a list Array with the cursor data in Android

查看:125
本文介绍了如何创建与Android的光标数据的列表阵列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何创建一个列表阵列(列表中显示第一字母时,滚动)用光标数据?

How can I create a list Array (the list display First Alphabet when scroll) with the cursor data?

推荐答案

通过每一个元素进去的光标,并逐个添加它们一到的ArrayList

Go through every element in the Cursor, and add them one by one to the ArrayList.

ArrayList<WhateverTypeYouWant> mArrayList = new ArrayList<WhateverTypeYouWant>();
for(mCursor.moveToFirst(); !mCursor.isAfterLast(); mCursor.moveToNext()) {
    // The Cursor is now set to the right position
    mArrayList.add(mCursor.getWhateverTypeYouWant(WHATEVER_COLUMN_INDEX_YOU_WANT));
}

(更换 WhateverTypeYouWant 与任何类型你想的的ArrayList WHATEVER_COLUMN_INDEX_YOU_WANT 与您希望从游标来获取值的列索引。)

(replace WhateverTypeYouWant with whatever type you want to make a ArrayList of, and WHATEVER_COLUMN_INDEX_YOU_WANT with the column index of the value you want to get from the cursor.)

这篇关于如何创建与Android的光标数据的列表阵列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆