Need TextFieldBoxes.getExtentedEdittext() method
Closed this issue · 2 comments
dineshmm23 commented
protected ExtendedEditText findEditTextChild() {
if (getChildCount() > 0 && getChildAt(0) instanceof ExtendedEditText)
return (ExtendedEditText) getChildAt(0);
return null;
}
Need this method to public... Unable use other view
public class TextInputLayoutAdapter implements ViewDataAdapter<TextInputLayout, String> {
@Override
public String getData(final TextInputLayouttil) {
return getText(til);
}
private String getText(TextInputLayout til) {
return til.getEditText().getText().toString();// i want use TextFieldBoxes instead of TextInputLayout
//Need to find EditText to get text of it.
}
}
HITGIF commented
TextFieldBoxes
and ExtendedEditText
are two separate instances. ExtendedEditText
is wrapped in TextFieldBoxes
, as shown in the example in the README:
<studio.carbonylgroup.textfieldboxes.TextFieldBoxes
android:id="@+id/text_field_boxes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:labelText="Label"
>
<studio.carbonylgroup.textfieldboxes.ExtendedEditText
android:id="@+id/extended_edit_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</studio.carbonylgroup.textfieldboxes.TextFieldBoxes>
To get the text, or to perform any action regarding the ExtendedEditText
, simply find its view by id
without needing to bother the TextFieldBoxes
, like this:
final ExtendedEditText extendedEditText = findViewById(R.id.extended_edit_text);
String text = extendedEditText.getText();
dineshmm23 commented
The TextInputLayoutAdapter
Class needs to dynamic, so that i can get text of ExtentedEdittext
using TextFieldBoxes
.
Hence, i found it another way use textwatcher
--->
public class TextInputLayoutAdapter implements ViewDataAdapter<TextFieldBoxes, String> {
private String res;
@Override
public String getData(final TextFieldBoxes tfb) {
return getText(tfb);
}
private String getText(TextFieldBoxes tfb) {
tfb.setSimpleTextChangeWatcher(new SimpleTextChangedWatcher() {
@Override
public void onTextChanged(String s, boolean b) {
res = s;
}
});
return res.toString();
}
}
I hope we can get the text directly using TextFieldBoxes