简体   繁体   中英

How to change ListView Item programmatically in Android?

I have a ListView and I want to change the listitem of it programmatically. Is there any way to do this? Thank you in advance.

This is my ListView XML code.

<ListView
    android:id="@+id/foodsListView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:divider="@android:color/transparent"
    android:stackFromBottom="false"
    android:transcriptMode="disabled"
    tools:listitem="@layout/item_food">
</ListView>

And here is what I want to show instead of item_food :

"R.layout.item_message"

Use RecyclerView instead of ListView. It was create for this t

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