override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) verticalLayout { padding = dip(30) editText { hint = "Name" textSize = 24f } editText { hint = "Password" textSize = 24f }
editText { hint ="Name" textSize = 24f } editText { hint ="Password" textSize = 24f } button("Login") { textSize = 26f } } 这仅仅是扩展函数表达式的一个发展分支。它们会创建这些类的实例,把它们加到它们的父亲那里,设置合适的属性。除了我们在 XML 里面使用的概念以外,比如 layout,你可以调用...
<EditText android:id="@+id/full_name" style="@style/TextAppearance.AppCompat.Title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:hint="@string/first_name" /> 这使用了一个 Android 样式TextAppearance.AppCompat.Title来显示标题,如下所示: 图1.21:带提示的 Ed...
hintResource=R.string.title_hint}button{textResource=R.string.add_todo onClick{view->{// 可以在这里添加一些处理逻辑title.text="Foo"}}} 可以看到在button布局中的onClick监听函数中,因为我们是使用 Kotlin代码来设计视图,所以可以直接使用title变量(editText视图对象)。 13.3 快速入门实例 下面我们通过一个...
editText { hint = "Password" textSize = 24f } button("Login") { textSize = 26f...
/> <Button android:id ="@+id/button1" android:layout_width="match_parent" android:layout_height="wrap_content" android:text ="@string/click_me" /> <EditText android:id ="@+id/editText1" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint ="@string/...
<EditText android:id="@+id/editText" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Type something here" /> </LinearLayout> 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 这里只是在布局中加入了一个EditText,用于输入文本内容。
id = R.id.todo_titlehintResource = R.string.title_hint}button{ textResource = R.string.add_todoonClick { view -> {// 可以在这里添加一些处理逻辑title.text="Foo"} } } } 可以看到在button布局中的onClick监听函数中,因为我们是使用 Kotlin代码来设计视图,所以可以直接使用title变量(editText视图对...
我还有一个 EditText,我想在更改时使用 ButterKnife 显示一条消息: @OnTextChanged(R.id.input) fun test() { toast(1) } 但是,没有任何反应。我在函数中放置了一个断点 - 它甚至没有执行。 PS:我听说过 kotterknife,但是我看到了一个纯 Butterknife 的例子。
<EditTextandroid:id="@+id/inputText"android:layout_width="0dp"android:layout_height="wrap_content"android:layout_weight="1"android:hint="Type something here"android:maxLines="2"/><Buttonandroid:id="@+id/send"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text...