android – What is Anko?

Question:

Already converting my Android projects to Kotlin, in some research I've been carrying out, I mentioned several times a guy named Anko Kotlin.

What is this Anko guy? What it is? What is your goal?

Answer:

According to his GitHub it is a library to facilitate development for Android with mechanisms for Intents, Dialogs and toasts, Logging, Resources and dimensions and even corotinas, a Kotlin deficiency.

It also has a DSL for layouts . Example:

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

That's Kotlin syntax. Why use XML? 🙂

It has an enabler to retrieve data from SQLite. Example:

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

I put it on GitHub for future reference .

Scroll to Top