我正在从事涉及从联机数据库获取用户列表的j2me项目,然后我打算使用用户的名称填充列表,并且该数目可能非常大。我的问题是 - 你可以追加到列表中的项目数是否有限制?J2ME列表中项目的最大数量
HttpConnection hc = (HttpConnection);
String reply;
Connector.open("http://www.xxxxxxxxxxxx.com/......?xx=xx");
InputStream is = new hc.openInputStream();
int ch;
// Check the Content-Length first
long len = hc.getLength();
if(len!=-1) {
for(int i = 0;i<len;i++)
if((ch = is.read())!= -1)
reply += (char) ch;
} else {
// if the content-length is not available
while ((ch = is.read()) != -1)
reply += (char) ch;
}
is.close();
hc.close();
DataParser parser = new DataParser(reply); // This is a custom class I created to process the XML data returned from the server to split it into groups and put in an array.
List user list = new List("Users");
if (parser.moveToNext()) {
do {
list.append(parser.get(), null);
}
}
此代码似乎工作正常,但我的问题是,如果保持通话list.append(“”,空),会得到它的一个点时,一些异常被抛出,也许在的情况下, 50,000个名字(列表项)?
你能不能分享一下你已经开始的,我的意思是实际的实现而不是概念? –
这就是我可以添加的最好的,我从Android设备打字 – francis994
只需测试它! for(int i = 0; i <50000; i ++){list.append(“item”+ i);}它可能有效,但可能会令人无法接受。 – Meier