alexa

How to split Recycler view into 2 divisions based on type from a JSON file in Kotlin - in android studio ?

How to split Recycler view into 2 divisions based on type from a JSON file in Kotlin - in android studio ?

I ended up filtering through my json file and splitting it into 2 lists. One that contains all the card types, another for all the bank types. Then passing each through their individual recycler.

 val cardData: MutableList <Data> = mutableListOf<Data>()
        val bankData: MutableList <Data> = mutableListOf<Data>()

        for(i in data) {
            if (i.account_type.equals("card")){
                cardData.add(i)
        }
    }

        for(i in data) {
            if (i.account_type.equals("bank")){
                bankData.add(i)
            }
        } 

To clarify, data is a list that uses the helper class Data using Gson, assign the json file to it in my main activity.


270 0
7

Write a Comments


* Be the first to Make Comment

GoodFirms Badge
GoodFirms Badge

Fix Your Meeting With Our SEO Consultants in India To Grow Your Business Online

Facebook
Twitter
LinkedIn
Instagram
Whatsapp
Call Now
Quick Inquiry