Hey there. I'm trying to render a textInputLayout, but my app keeps crashing during the second render-cycle with the following exception: java.lang.IllegalArgumentException: We already have an EditText, can only have one
The view looks like this:
DesignDSL.textInputLayout(() -> {
DSL.layoutGravity(DSL.TOP);
DesignDSL.hint(getContext().getString(R.string.connect_hint_port));
DesignDSL.textInputEditText(() -> {
DSL.inputType(InputType.TYPE_CLASS_NUMBER);
DSL.enabled(state.connect().state() != State.CONNECT_STATE.CONNECTING);
DSL.text(String.valueOf(state.connect().port()));
DSL.onTextChanged((s) -> {
App.getInstance().getStore().dispatch(new Action("CONNECT_SET_PORT",s.toString()));
});
});
});
I also tried using a standard DSL.editText()
but still not working.. Thanks!
android.jar
. I normally use sdk-19 these days, but you may choose either of them../gradlew publishToMavenLocal
and give it a try!
public void view() {
linearLayout(() -> {
button(() -> { // Inside any view block...
init(() -> { // you may declare "init" function and pass lambda into it
Button b = Anvil.currentView(); // Type of a view is deduced automatically in most cases
mButton = (Button) Anvil.currentView(); // Or you may cast it explicitly
// You are not forced to do this within "init" block, but otherwise your code will be called on every rendering cycle
})
});
});
}
// later on you may use mButton as a normal view:
mButton.performClick();
button(() -> {
id(MY_BUTTON);
});
// later just find view by ID, IIRC Android caches views and their IDs:
findViewByID(MY_BUTTON).performClick();