eltos / SimpleDialogFragments

An Android library to create dialogs with ease and handle user interaction reliably, using fragments and material design.
Apache License 2.0
119 stars 17 forks source link

InputDialog strange log #1

Closed azizkayumov closed 7 years ago

azizkayumov commented 7 years ago

I have tried this for simple name input:

SimpleInputDialog.build()
                .msg(getString(R.string.enter_flashcard_name))
                .inputType(InputType.TYPE_CLASS_TEXT)
                .show(MainActivity.this);

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?

azizkayumov commented 7 years ago

http://stackoverflow.com/questions/39655910/textinputlayout-edittext-added-is-not-a-textinputedittext-please-switch-to-usi

eltos commented 7 years ago

Am I right that this is just a warning and the dialog still behaves as expected?

eltos commented 7 years ago

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.

See http://stackoverflow.com/a/41864063/4961701

eltos commented 7 years ago

By the way, TYPE_CLASS_TEXT is the default InputType, no need to explicitly set it ;)

azizkayumov commented 7 years ago

But there is nothing on onResult, it is not giving me the entered text by user, it just shows the log, that's it!

azizkayumov commented 7 years ago

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

eltos commented 7 years ago

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;
}
azizkayumov commented 7 years ago

Thanks Eltos, I did this!