简体   繁体   中英

Android: listview with different items (optimization)

I'm reading this tutorial http://android.amberfog.com/?p=296 . I have just a question: if I definire an xml layout like this one:

 <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. For the item type C id1, id2 and 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)? Thank you in advance

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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