Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Prompt for the username
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setTitle("Votre nom d'utilisateur");
- // Set up the input TODO: style
- final EditText input = new EditText(this);
- input.setInputType(InputType.TYPE_CLASS_TEXT);
- builder.setView(input);
- // Set up the buttons
- builder.setNegativeButton("Défaut", (dialog, which) -> {
- newUser.setUserName("UserNameOf_" + uId);
- postAndSyncUser(newUser);
- });
- builder.setPositiveButton("OK", (dialog, which) -> {
- if(input.getText().toString().length() > 0 ) {
- // TODO: intégrer une vérification pour que les 'userName' soient uniques?
- newUser.setUserName(input.getText().toString());
- } else {
- newUser.setUserName("UserNameOf_" + uId);
- }
- postAndSyncUser(newUser);
- });
- // Show dialog
- AlertDialog dialog = builder.create();
- dialog.setOnShowListener(d -> {
- InputMethodManager inM = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
- inM.showSoftInput(input, InputMethodManager.SHOW_IMPLICIT);
- });
- dialog.show();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement