Skip to content

Instantly share code, notes, and snippets.

@fnzainal
Created April 12, 2016 04:27
Show Gist options
  • Save fnzainal/b6457cd664cfb8d1e294d54003bebc86 to your computer and use it in GitHub Desktop.
Save fnzainal/b6457cd664cfb8d1e294d54003bebc86 to your computer and use it in GitHub Desktop.
show dialog to input text with lib Material Dialogs
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