简体   繁体   English

Android:具有不同项目的列表视图(优化)

[英]Android: listview with different items (optimization)

I'm reading this tutorial http://android.amberfog.com/?p=296 . 我正在阅读本教程http://android.amberfog.com/?p=296 I have just a question: if I definire an xml layout like this one: 我有一个问题:如果我定义这样的xml布局:

 <LinearLayout>

    <ListView/>

    <TextView android:id="@+id/id1" />

    <TextView android:id="@+id/id2" />

    <ImageView android:id="@+id/id3" />

    <TextView android:id="@+id/id4" />

</LinearLayout>

Now, suppose that to show the item type AI use the Textview id1 and id2: For the item type BI use id1 and the imageview id3. 现在,假设要显示项目类型AI,请使用Textview id1和id2:对于项目类型BI,请使用id1和imageview id3。 For the item type C id1, id2 and id3. 对于项目类型C,id1,id2和id3。 For the item type D the id4, etc etc. In a case like this, having textviews and imageviews (in the xml layout) which will not be used by every item in the listview, will it be slow (in performance)? 对于项类型D,则为id4等, 在这种情况下,拥有不会被列表视图中的每个项使用的textview和imageview(在xml布局中),会不会很慢(性能)? Thank you in advance 先感谢您

如果使用的是适配器,则可以为每种类型的项目创建单独的布局,并在适配器的getView方法中getView不同的布局。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM