我有超过 10000 个城市名称,我想在 ListView 中显示。我将这些名称存储为 city.xml 文件res/values folder
像下面
<resources>
<string-array name="city">
<item> chennai, India </item>
<item> Spring Creek , Australia </item>
.
.
然后我创建一个 ArrayAdapter 并像这样填充到 listView 。
String[] cityDetails = res.getStringArray(R.array.city); // <-- getting Error in this line
myAdapter = new ArrayAdapter<String>(this, R.layout.ap_details_row, R.id.aNameTV, cityDetails );
myLV.setAdapter(myAdapter);
它在 API 级别 13 及更高级别的设备中运行良好。但在 API 级别 13 设备以下,我收到以下错误。
W/dalvikvm(306): ReferenceTable overflow (max=512)
W/dalvikvm(306): Last 10 entries in JNI local reference table:
W/dalvikvm(306): 502: 0x45fbb330 cls=Ljava/lang/String; (28 bytes)
W/dalvikvm(306): 503: 0x45fbb388 cls=Ljava/lang/String; (28 bytes)
W/dalvikvm(306): 504: 0x45fbb3e0 cls=Ljava/lang/String; (28 bytes)
W/dalvikvm(306): 505: 0x45fbb438 cls=Ljava/lang/String; (28 bytes)
W/dalvikvm(306): 506: 0x45fbb498 cls=Ljava/lang/String; (28 bytes)
W/dalvikvm(306): 507: 0x45fbb4f8 cls=Ljava/lang/String; (28 bytes)
W/dalvikvm(306): 508: 0x45fbb558 cls=Ljava/lang/String; (28 bytes)
W/dalvikvm(306): 509: 0x45fbb5d0 cls=Ljava/lang/String; (28 bytes)
W/dalvikvm(306): 510: 0x45fbb638 cls=Ljava/lang/String; (28 bytes)
W/dalvikvm(306): 511: 0x45fbb698 cls=Ljava/lang/String; (28 bytes)
W/dalvikvm(306): JNI local reference table summary (512 entries):
W/dalvikvm(306): 3 of Ljava/lang/Class; 164B (2 unique)
W/dalvikvm(306): 507 of Ljava/lang/String; 28B (507 unique)
W/dalvikvm(306): 1 of [Ljava/lang/String; 28B
W/dalvikvm(306): 1 of [Ljava/lang/String; 37436B
W/dalvikvm(306): Memory held directly by tracked refs is 51988 bytes
E/dalvikvm(306): Failed adding to JNI local ref table (has 512 entries)
I/dalvikvm(306): "main" prio=5 tid=1 RUNNABLE
I/dalvikvm(306): | group="main" sCount=0 dsCount=0 s=N obj=0x4001d8e0 self=0xccb0
I/dalvikvm(306): | sysTid=306 nice=0 sched=0/0 cgrp=default handle=-1345026008
I/dalvikvm(306): | schedstat=( 1050455605 562911400 652 )
I/dalvikvm(306): at android.content.res.AssetManager.getArrayStringResource(Native Method)
I/dalvikvm(306): at android.content.res.AssetManager.getResourceStringArray(AssetManager.java:186)
I/dalvikvm(306): at android.content.res.Resources.getStringArray(Resources.java:381)
I/dalvikvm(306): at com.mypro.main.HomeActivity.onCreate(HomeActivity.java:184)
I/dalvikvm(306): at dalvik.system.NativeStart.main(Native Method)
E/dalvikvm(306): VM aborting
任何帮助,将不胜感激。