What is the Anko?

Asked

Viewed 296 times

6

Already converting my Android projects to Kotlin, in some researches I’ve been doing, several times quoted a Anko Kotlin.

What is this Anko? What is this about? What is your goal?

  • Who denied the question could at least explain the reason why I can edit it and try to collaborate more with the OS.

2 answers

7

It is a library for Kotlin aimed specifically at the development of Android applications, with the aim of making the code simpler and readable, dispensing the programmer from having to get involved with the deeper details of the Android SDK for Java.

You can find a more detailed description with examples in: https://www.thiengo.com.br/iniciando-com-anko-kotlin-intencoes-no-android

7


According to the Github of his is a library to facilitate development for Android with mechanisms for Intents, Dialogs and toasts, Logging, Resources and Dimensions and even corollaries, a Kotlin deficiency.

It also has a DSL for layouts. Example:

verticalLayout {
    val name = editText()
    button("Say Hello") {
        onClick { toast("Hello, ${name.text}!") }
    }
}

This is Kotlin syntax. Why use XML? :)

Has a facilitator to recover data from Sqlite. Example:

fun getUsers(db: ManagedSQLiteOpenHelper): List<User> = db.use {
    db.select("Users")
            .whereSimple("family_name = ?", "John")
            .doExec()
            .parseList(UserParser)
}

I put in the Github for future reference.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.