Loading data to ListView from XML file using Kotlin Code

Having the data to load in ListView managed under an XML file greatly helps maintaining and upgrading the app especially with additional content. Usually beginners are taught ListView with data hard coded in one of the activity files and pushed as Array in ListView using adapter.

I myself has recently learnt about ListView and now working on employing it for different purposes. However, I found no tutorial on parsing XML data file to ListView with Kotlin code to develop android application. So I think this video walk-through, though audio less, will help the beginners understanding the simple steps they need to take to feed ListView with data from an XML file saved as a resource inside app.

Apologize for no audio as I am currently working on setting up my microphone properly so that I don’t bore the learners with amateur audio settings and keystrokes and vibrations being picked up by microphone. So until then, I hope this will be of help.

Also pardon the black pillars on each side, I have corrected the resolution now and future videos will annoyance free.

Kotlin Codes

Following are the relevant codes for each part of the app used to build the app.

Remember, pasting these codes require caution as some existing codes in your IDE should or should not be removed depending on each file. Pay very close attention to the video walkthrough to see where the code needs to go!

Main Activity

XML file

activity_main

 

Leave a Reply

avatar
  Subscribe  
Notify of