Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Interface Entry does not have constructors

I’m trying to make edits for multiple contacts depending on the user’s contacts saved by countries. But, when trying to access the entry of the map, the warning below appears.
Thank you…

Interface Entry does not have constructors

for ((key, value) in Map.Entry<String, Array<String>> in dialCodes) {
            val code = key.uppercase()
            val countryName = Locale("", code).displayCountry
            if (TextUtils.isEmpty(countryName)) {
                Log.w(TAG, "Country name missing for '$code'")
            }
            for (prefix in value) {
                countryList.add(CountryCode(code, countryName, prefix.trim { prefix <= ' ' }))
            }
            Collections.sort(countryList)
        }

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Warning message you’re encountering is due to an incorrect usage of the Map.Entry interface

You should iterate through the entries of a map, not directly create entries using the Map.Entry interface.

val dialCodes: Map<String, Array<String>> = mapOf(
    // Initialize your map with key-value pairs
)

val countryList = mutableListOf<CountryCode>()

for ((key, value) in dialCodes) {
    val code = key.uppercase()
    val countryName = Locale("", code).displayCountry
    if (TextUtils.isEmpty(countryName)) {
        Log.w(TAG, "Country name missing for '$code'")
    }
    for (prefix in value) {
        countryList.add(CountryCode(code, countryName, prefix.trim { it <= ' ' }))
    }
}

Collections.sort(countryList)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading