如何使用无限数量的列表制作自定义ListView

时间:2011-07-18 13:53:43

标签: android listview

我想用1000多首歌曲制作自定义列表视图。但在我的应用程序中,200首歌曲listview工作正常,但当我添加400多首歌曲时,应用程序就会关闭。 在logcat中,我得到了这些消息。

    07-18 18:59:35.625: ERROR/IMemory(625): binder=0x596550 transaction failed fd=-2147483647, size=0, err=-2147483646 (Unknown error: 2147483646)
07-18 18:59:35.625: ERROR/IMemory(625): cannot dup fd=-2147483647, size=0, err=-2147483646 (Bad file number)
07-18 18:59:35.625: ERROR/IMemory(625): cannot map BpMemoryHeap (binder=0x596550), size=0, fd=-1 (Bad file number)
07-18 18:59:35.625: ERROR/JavaBinder(625): *** Uncaught remote exception!  (Exceptions are not yet supported across processes.)
07-18 18:59:35.625: ERROR/JavaBinder(625): java.lang.RuntimeException: No memory in memObj
07-18 18:59:35.625: ERROR/JavaBinder(625):     at android.database.CursorWindow.native_init(Native Method)
07-18 18:59:35.625: ERROR/JavaBinder(625):     at android.database.CursorWindow.<init>(CursorWindow.java:518)
07-18 18:59:35.625: ERROR/JavaBinder(625):     at android.database.CursorWindow.<init>(CursorWindow.java:27)
07-18 18:59:35.625: ERROR/JavaBinder(625):     at android.database.CursorWindow$1.createFromParcel(CursorWindow.java:493)
07-18 18:59:35.625: ERROR/JavaBinder(625):     at android.database.CursorWindow$1.createFromParcel(CursorWindow.java:496)
07-18 18:59:35.625: ERROR/JavaBinder(625):     at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:103)
07-18 18:59:35.625: ERROR/JavaBinder(625):     at android.os.Binder.execTransact(Binder.java:288)
07-18 18:59:35.625: ERROR/JavaBinder(625):     at dalvik.system.NativeStart.run(Native Method)
07-18 18:59:35.635: ERROR/IMemory(625): binder=0x597b10 transaction failed fd=-2147483647, size=0, err=-2147483646 (Unknown error: 2147483646)
07-18 18:59:35.635: ERROR/IMemory(625): cannot dup fd=-2147483647, size=0, err=-2147483646 (Bad file number)
07-18 18:59:35.635: ERROR/IMemory(625): cannot map BpMemoryHeap (binder=0x597b10), size=0, fd=-1 (Bad file number)
07-18 18:59:35.635: ERROR/JavaBinder(625): *** Uncaught remote exception!  (Exceptions are not yet supported across processes.)

请告诉我我哪里出错了。

1 个答案:

答案 0 :(得分:0)

在ListView中有超过1000首歌曲。这意味着您一次会在屏幕上拥有1,000多个活动视图。我大多肯定这太过分了。您收到这些错误是因为您内存不足。也许你应该试着对你如何显示歌曲更加聪明一些,比如在滚动时有一个大约100的工作视图。它会更复杂,但它应该有用。