Comments (4)
Update:
I got this working by using an instance variable, like so:
var nameBox: EditText? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
relativeLayout {
verticalLayout {
val name = editText() {
id = nameId
}
nameBox = name
}
button("Register") {
onClick {
toast("Hello, ${nameBox!!.text}!")
}
}
}
}
from anko.
better use var nameBox: EditText by Delgates.notNull()
from anko.
Excellent. I'm a Kotlin newbie and was unaware of that. Thanks again and sorry for not reading the docs more closely!
from anko.
Just in case: Kotlin now has late-initialized variables (https://kotlinlang.org/docs/reference/properties.html#late-initialized-properties) which don't create an extra delegate object.
from anko.
Related Issues (20)
- Alerts with no system bar, or: how to get dialog before show() ? HOT 1
- How to use linearLayout in verticalLayout? HOT 1
- hintTextColor can not work in anko? HOT 1
- Error: void org.jetbrains.anko.appcompat.v7._AlertDialogLayout.forceUniformWidth(int, int) is not being kept as e, but remapped to d
- Feature request: share file
- Android Q support
- Maybe Not update anymore for this project? HOT 1
- Maybe Not update anymore for this project? HOT 11
- Is this project discontinued? HOT 5
- Textview cannot accept new line from Resources strings HOT 2
- something issues of anko.include() dsl
- ***** BEWARE -- this project seems to be abandoned. ***** HOT 14
- Fix reference - Listeners not working HOT 1
- about Anko performance HOT 8
- Selector no cancel listener HOT 1
- textView.setMaxWidth() does not work
- Is SDK28 Available In A Repo Somewhere? HOT 1
- Style selector text? HOT 1
- Please archive this repository. HOT 3
- What if I don't want to add the view directly?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from anko.