Closed azizkayumov closed 7 years ago
Am I right that this is just a warning and the dialog still behaves as expected?
It's probably because I am using an AutoCompleteTextView
(which is a subclass of EditText
) rather than TextInputEditText
.
Unfortunately there is no aquivalent in the support library, so I'd have to make my own implementation of it. It seems to be straightforward though.
By the way, TYPE_CLASS_TEXT
is the default InputType, no need to explicitly set it ;)
But there is nothing on onResult, it is not giving me the entered text by user, it just shows the log, that's it!
The dialog still behaves as expected, but there is NO result, without result, it is just a dialog which user can enter some text, but you can't deal with the text
I see. Well that's because you have called the show
method without a tag.
A tag is required to receive results, so that you can match the results from different dialogs in the onResult
method. Even if there is only one dialog in an activity, a tag has to be supplied, otherwise onResult
will never get called! (I probably should point that out in the docs; sorry I'm still working on that wiki)
Try this:
final static String FLASHCARD_DIALOG = "flashcard_dialog_tag";
SimpleInputDialog.build()
.msg(R.string.enter_flashcard_name)
.show(MainActivity.this, FLASHCARD_DIALOG);
@Override
public boolean onResult(@NonNull String dialogTag, int which, @NonNull Bundle extras) {
if (FLASHCARD_DIALOG.equals(dialogTag) && which == BUTTON_POSITIVE){
String name = extras.getString(SimpleInputDialog.TEXT);
// ...
return true;
}
return false;
}
Thanks Eltos, I did this!
I have tried this for simple name input:
But in logcat, it gives this:
I/TextInputLayout: EditText added is not a TextInputEditText. Please switch to using that class instead.
and it makes me nervous, what the hell did I do wrong?