列出j2me的所有记录

发布于 2024-12-12 22:35:19 字数 473 浏览 9 评论 0原文

我想列出唱片店中的所有记录。我已经声明了一个列表:

Private List tlist = new List("Select One", List.IMPLICIT);

还枚举了记录:

Form mainf;
Command exit = new Command("Exit", Command.EXIT, 0);
RecordEnumeration re = null;
int numrecords = 0;
    try {
        re = contactList.enumerateRecords(null, null, false);
        numrecords = re.numRecords();
    } catch (RecordStoreException rse ) { numrecords = 0;}

现在我只需要知道如何列出列表中的所有记录。

I want to list all records in the record store. I've declared a list:

Private List tlist = new List("Select One", List.IMPLICIT);

Also enumerated the records:

Form mainf;
Command exit = new Command("Exit", Command.EXIT, 0);
RecordEnumeration re = null;
int numrecords = 0;
    try {
        re = contactList.enumerateRecords(null, null, false);
        numrecords = re.numRecords();
    } catch (RecordStoreException rse ) { numrecords = 0;}

Now I just need to know how to list all the records in a list.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

誰認得朕 2024-12-19 22:35:19

Record 添加到 Vector 中,并使用循环将 Vector 值附加到 List 中。请参阅下面的示例代码,

RecordStore s =  RecordStore.openRecordStore(recordStoreName, true);
RecordEnumeration e = s.enumerateRecords(null, null, false);
Vector vector = new Vector();
while(e.hasNextElement()) {
  vector.addElement(new String(e.nextRecord()));
}
List l = new List(null, CENTER);
for (int i = 0; i < vector.size(); i++) {
  l.append(vector.elementAt(i).toString(), null); 
}

Add the Record into Vector and use the loop for append the Vector values into List. See below sample code,

RecordStore s =  RecordStore.openRecordStore(recordStoreName, true);
RecordEnumeration e = s.enumerateRecords(null, null, false);
Vector vector = new Vector();
while(e.hasNextElement()) {
  vector.addElement(new String(e.nextRecord()));
}
List l = new List(null, CENTER);
for (int i = 0; i < vector.size(); i++) {
  l.append(vector.elementAt(i).toString(), null); 
}
抱着落日 2024-12-19 22:35:19

您可以使用以下代码,

public String [] getRecordData()
{
    String[] str = null;
    int counter = 0;
    try 
    {
        RecordEnumeration enumeration = rs.enumerateRecords(null, null, false);
        str = new String[rs.getNumRecords()];

        while(enumeration.hasNextElement())
        {
            try 
            {
                str[counter] = (new String(enumeration.nextRecord()));
                counter ++;
            } 
            catch (Exception e) 
            {
                e.printStackTrace();
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return str;
}

you can use following code,

public String [] getRecordData()
{
    String[] str = null;
    int counter = 0;
    try 
    {
        RecordEnumeration enumeration = rs.enumerateRecords(null, null, false);
        str = new String[rs.getNumRecords()];

        while(enumeration.hasNextElement())
        {
            try 
            {
                str[counter] = (new String(enumeration.nextRecord()));
                counter ++;
            } 
            catch (Exception e) 
            {
                e.printStackTrace();
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return str;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文