Created
April 12, 2016 04:27
-
-
Save fnzainal/b6457cd664cfb8d1e294d54003bebc86 to your computer and use it in GitHub Desktop.
show dialog to input text with lib Material Dialogs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.afollestad.materialdialogs.MaterialDialog.Builder; | |
new MaterialDialog.Builder(this) | |
.content("Enter your name") | |
.inputRange(5,20) | |
.cancelable(false) | |
.inputType(InputType.TYPE_TEXT_FLAG_CAP_WORDS) | |
.input("your name", null, new MaterialDialog.InputCallback() { | |
@Override | |
public void onInput(MaterialDialog dialog, CharSequence input) { | |
String name = input.toString(); | |
Log.d("input_name", name); | |
SharedPreferences.Editor editor = myPrefrence.edit(); | |
editor.putString("name", name); | |
editor.apply(); | |
tv.setText(input.toString()); | |
Snackbar.make(navLayout,"Have a nice day, "+name+"!",Snackbar.LENGTH_SHORT).show(); | |
} | |
}); | |
.show(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment