Example usage for android.text InputType TYPE_TEXT_VARIATION_EMAIL_ADDRESS

List of usage examples for android.text InputType TYPE_TEXT_VARIATION_EMAIL_ADDRESS

Introduction

In this page you can find the example usage for android.text InputType TYPE_TEXT_VARIATION_EMAIL_ADDRESS.

Prototype

int TYPE_TEXT_VARIATION_EMAIL_ADDRESS

To view the source code for android.text InputType TYPE_TEXT_VARIATION_EMAIL_ADDRESS.

Click Source Link

Document

Variation of #TYPE_CLASS_TEXT : entering an e-mail address.

Usage

From source file:de.gadc.moneybeam.MoneyBeamActivity.java

/**
 * This method presents the user the dialog that enables him to enter his
 * email address./*from  w  w w .  j a  va 2  s.  co  m*/
 */
private void showEmailDialog() {
    final EditText editText = new EditText(this);
    AlertDialog.Builder emailDialogBuilder = new Builder(this);
    emailDialogBuilder.setTitle(R.string.hint_email);
    editText.setImeOptions(EditorInfo.IME_ACTION_DONE);
    editText.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
    emailDialogBuilder.setView(editText);
    emailDialogBuilder.setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            String mail = editText.getText().toString();
            prefs.edit().putString(Configuration.PREF_MAIL, mail).commit();
        }
    });
    emailDialogBuilder.setNegativeButton(R.string.button_cancel, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    emailDialogBuilder.show();
}

From source file:id.satusatudua.sigap.ui.fragment.TrustedsFragment.java

@OnClick(R.id.fab)
public void addNewContact() {
    EditText editText = new EditText(getActivity());
    editText.setHint("Email");
    editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
    AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).setIcon(R.mipmap.ic_launcher)
            .setTitle("Masukan alamat email kontak").setView(editText)
            .setPositiveButton("Kirim", (dialog, which) -> {
                String email = editText.getText().toString();

                if (!Patterns.EMAIL_ADDRESS.matcher(email).matches()) {
                    showError("Mohon masukan alamat email yang valid!");
                } else if (email.equalsIgnoreCase(CacheManager.pluck().getCurrentUser().getEmail())) {
                    showError("Mohon masukan alamat email selain email anda sendiri!");
                } else {
                    trustedUserPresenter.searchUser(email);
                    KeyboardUtil.hideKeyboard(getActivity(), editText);
                    dialog.dismiss();/*  www  .  j  av  a  2  s.  c  o m*/
                }
            }).setNegativeButton("Batal", (dialog, which1) -> {
                dialog.dismiss();
            }).show();

    alertDialog.getButton(DialogInterface.BUTTON_POSITIVE)
            .setTextColor(ContextCompat.getColor(getActivity(), R.color.colorPrimary));
    alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE)
            .setTextColor(ContextCompat.getColor(getActivity(), R.color.primary_text));
    alertDialog.show();
}

From source file:com.parse.ui.ParseLoginFragment.java

private void setUpParseLoginAndSignup() {
    parseLogin.setVisibility(View.VISIBLE);

    if (config.isParseLoginEmailAsUsername()) {
        usernameField.setHint(R.string.com_parse_ui_email_input_hint);
        usernameField.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
    }//w  w w. ja  va2s . c o  m

    if (config.getParseLoginButtonText() != null) {
        parseLoginButton.setText(config.getParseLoginButtonText());
    }

    parseLoginButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            String username = usernameField.getText().toString();
            String password = passwordField.getText().toString();

            if (username.length() == 0) {
                if (config.isParseLoginEmailAsUsername()) {
                    showToast(R.string.com_parse_ui_no_email_toast);
                } else {
                    showToast(R.string.com_parse_ui_no_username_toast);
                }
            } else if (password.length() == 0) {
                showToast(R.string.com_parse_ui_no_password_toast);
            } else {
                loadingStart(true);
                ParseUser.logInInBackground(username, password, new LogInCallback() {
                    @Override
                    public void done(ParseUser user, ParseException e) {
                        if (isActivityDestroyed()) {
                            return;
                        }

                        if (user != null) {
                            loadingFinish();
                            loginSuccess();
                        } else {
                            loadingFinish();
                            if (e != null) {
                                debugLog(getString(R.string.com_parse_ui_login_warning_parse_login_failed)
                                        + e.toString());
                                if (e.getCode() == ParseException.OBJECT_NOT_FOUND) {
                                    if (config.getParseLoginInvalidCredentialsToastText() != null) {
                                        showToast(config.getParseLoginInvalidCredentialsToastText());
                                    } else {
                                        showToast(R.string.com_parse_ui_parse_login_invalid_credentials_toast);
                                    }
                                    passwordField.selectAll();
                                    passwordField.requestFocus();
                                } else {
                                    showToast(R.string.com_parse_ui_parse_login_failed_unknown_toast);
                                }
                            }
                        }
                    }
                });
            }
        }
    });

    if (config.getParseSignupButtonText() != null) {
        parseSignupButton.setText(config.getParseSignupButtonText());
    }

    parseSignupButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            String username = usernameField.getText().toString();
            String password = passwordField.getText().toString();

            loginFragmentListener.onSignUpClicked(username, password);
        }
    });

    if (config.getParseLoginHelpText() != null) {
        parseLoginHelpButton.setText(config.getParseLoginHelpText());
    }

    parseLoginHelpButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            loginFragmentListener.onLoginHelpClicked();
        }
    });
}

From source file:com.amazonaws.mobile.auth.userpools.SignUpView.java

@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    this.signUpForm = (FormView) findViewById(R.id.signup_form);
    userNameEditText = signUpForm.addFormField(getContext(),
            InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PERSON_NAME,
            getContext().getString(R.string.username_text));

    passwordEditText = signUpForm.addFormField(getContext(),
            InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD,
            getContext().getString(R.string.sign_in_password));

    givenNameEditText = signUpForm.addFormField(getContext(),
            InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PERSON_NAME,
            getContext().getString(R.string.given_name_text));

    emailEditText = signUpForm.addFormField(getContext(),
            InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS,
            getContext().getString(R.string.email_address_text));

    phoneEditText = signUpForm.addFormField(getContext(), InputType.TYPE_CLASS_PHONE,
            getContext().getString(R.string.phone_number_text));

    this.signUpMessage = (TextView) findViewById(R.id.signup_message);
    this.signUpButton = (Button) findViewById(R.id.signup_button);

    setupSignUpButtonBackground();//from  w ww .  j  av  a2 s. c o m
    setupFontFamily();
}

From source file:com.auth0.android.lock.views.ValidatedInputView.java

private void setupInputValidation() {
    String hint = "";
    String error = "";
    input.setTransformationMethod(null);
    Log.v(TAG, "Setting up validation for field of type " + dataType);
    switch (dataType) {
    case EMAIL:// w ww  . j a va  2  s .  c o  m
        input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
        inputIcon = R.drawable.com_auth0_lock_ic_email;
        hint = getResources().getString(R.string.com_auth0_lock_hint_email);
        error = getResources().getString(R.string.com_auth0_lock_input_error_email);
        break;
    case PASSWORD:
        input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
        input.setTransformationMethod(PasswordTransformationMethod.getInstance());
        input.setTypeface(Typeface.DEFAULT);
        inputIcon = R.drawable.com_auth0_lock_ic_password;
        hint = getResources().getString(R.string.com_auth0_lock_hint_password);
        error = getResources().getString(R.string.com_auth0_lock_input_error_password);
        break;
    case USERNAME_OR_EMAIL:
        input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
        inputIcon = R.drawable.com_auth0_lock_ic_username;
        hint = getResources().getString(R.string.com_auth0_lock_hint_username_or_email);
        error = getResources().getString(R.string.com_auth0_lock_input_error_username_email);
        break;
    case TEXT_NAME:
        input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PERSON_NAME);
        inputIcon = R.drawable.com_auth0_lock_ic_username;
        hint = getResources().getString(R.string.com_auth0_lock_hint_username);
        error = getResources().getString(R.string.com_auth0_lock_input_error_empty);
        break;
    case NON_EMPTY_USERNAME:
        input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
        inputIcon = R.drawable.com_auth0_lock_ic_username;
        hint = getResources().getString(R.string.com_auth0_lock_hint_username);
        error = getResources().getString(R.string.com_auth0_lock_input_error_username_empty);
        break;
    case USERNAME:
        input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
        inputIcon = R.drawable.com_auth0_lock_ic_username;
        hint = getResources().getString(R.string.com_auth0_lock_hint_username);
        error = String.format(getResources().getString(R.string.com_auth0_lock_input_error_username),
                MIN_USERNAME_LENGTH, MAX_USERNAME_LENGTH);
        break;
    case NUMBER:
        input.setInputType(InputType.TYPE_CLASS_NUMBER);
        inputIcon = R.drawable.com_auth0_lock_ic_password;
        hint = getResources().getString(R.string.com_auth0_lock_hint_code);
        error = getResources().getString(R.string.com_auth0_lock_input_error_empty);
        break;
    case MFA_CODE:
        input.setInputType(InputType.TYPE_CLASS_NUMBER);
        inputIcon = R.drawable.com_auth0_lock_ic_password;
        hint = getResources().getString(R.string.com_auth0_lock_hint_code);
        error = getResources().getString(R.string.com_auth0_lock_input_error_code);
        break;
    case MOBILE_PHONE:
        input.setInputType(InputType.TYPE_CLASS_NUMBER);
        inputIcon = R.drawable.com_auth0_lock_ic_mobile;
        hint = getResources().getString(R.string.com_auth0_lock_hint_phone_number);
        error = getResources().getString(R.string.com_auth0_lock_input_error_phone_number);
        break;
    case PHONE_NUMBER:
        input.setInputType(InputType.TYPE_CLASS_PHONE);
        inputIcon = R.drawable.com_auth0_lock_ic_phone;
        hint = getResources().getString(R.string.com_auth0_lock_hint_phone_number);
        error = getResources().getString(R.string.com_auth0_lock_input_error_phone_number);
        break;
    }
    input.setHint(hint);
    errorDescription.setText(error);
    icon.setImageResource(inputIcon);
}

From source file:fr.bde_eseo.eseomega.events.tickets.TicketHistoryActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    // Set view / call parent
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_event_history);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    context = this;

    // Get profile
    // Get user's data
    userProfile = new UserProfile();
    userProfile.readProfilePromPrefs(context);

    // Layout/*from www  . jav a 2 s .c om*/
    progressLoad = (ProgressBar) findViewById(R.id.progressTicketList);
    progressToken = (ProgressBar) findViewById(R.id.progressLoading);
    progressLoad.setVisibility(View.GONE);
    progressLoad.getIndeterminateDrawable().setColorFilter(getResources().getColor(R.color.md_grey_500),
            PorterDuff.Mode.SRC_IN);
    progressToken.setVisibility(View.INVISIBLE);
    progressToken.getIndeterminateDrawable().setColorFilter(getResources().getColor(R.color.md_white_1000),
            PorterDuff.Mode.SRC_IN);
    tvNothing = (TextView) findViewById(R.id.tvListNothing);
    tvNothing2 = (TextView) findViewById(R.id.tvListNothing2);
    imgNothing = (ImageView) findViewById(R.id.imgNoCommand);
    tvNothing.setVisibility(View.GONE);
    tvNothing2.setVisibility(View.GONE);
    imgNothing.setVisibility(View.GONE);
    viewToken = findViewById(R.id.viewCircle);
    viewToken.setVisibility(View.INVISIBLE);

    // Get file from cache directory
    String cachePath = getCacheDir() + "/";
    cacheTicketsJSON = new File(cachePath + "tickets.json");

    // Init model  get it from TicketStore
    eventTicketItems = TicketStore.getInstance().getEventTicketItems();

    // Init adapter / recycler view
    mAdapter = new MyTicketAdapter(context);
    recList = (RecyclerView) findViewById(R.id.cardTickets);
    recList.setHasFixedSize(true);
    LinearLayoutManager llm = new LinearLayoutManager(context);
    llm.setOrientation(LinearLayoutManager.VERTICAL);
    recList.setLayoutManager(llm);
    recList.setAdapter(mAdapter);
    recList.setVisibility(View.GONE);

    // Attach floating action button
    fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.attachToRecyclerView(recList);

    // On click listener for token
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            TimeZone tz = Calendar.getInstance().getTimeZone();
            String tzStr = tz.getID();

            if (!userProfile.isCreated()) {
                new MaterialDialog.Builder(context).title("Vous n'tes pas connect").content(
                        "Nous avons besoin de savoir qui vous tes avant de pouvoir vous laisser effectuer une rservation.")
                        .negativeText("D'accord").cancelable(false).show();
            } else if (false && !tzStr.equalsIgnoreCase(Constants.TZ_ID_PARIS)) {
                new MaterialDialog.Builder(context).title("Erreur").content(
                        "L'accs aux rservations ne peut se faire depuis un autre pays que la France.\nEnvoyez nous une carte postale !")
                        .negativeText("D'accord").cancelable(false).show();
            } else {
                SyncToken syncToken = new SyncToken();
                syncToken.execute();
            }
        }
    });

    // Recycler listener
    recList.addOnItemTouchListener(
            new RecyclerItemClickListener(context, new RecyclerItemClickListener.OnItemClickListener() {
                @Override
                public void onItemClick(View view, int position) {

                    final int idcmd = eventTicketItems.get(position).getIdcmd();

                    new MaterialDialog.Builder(context).title("Renvoyer l'email").content(
                            "Vous avez perdu votre place, vous ne retouvez plus le mail associ ?\nPas de soucis, vous avez la possibilit de recevoir de nouveau votre place ...")
                            .negativeText(R.string.dialog_cancel).callback(new MaterialDialog.ButtonCallback() {
                                @Override
                                public void onNegative(MaterialDialog dialog) {
                                    Utilities.hideKeyboardFromActivity(TicketHistoryActivity.this); // Doesn't works ...
                                    super.onNegative(dialog);
                                }
                            }).inputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS)
                            .input("sterling@archer.fr", "", new MaterialDialog.InputCallback() {
                                @Override
                                public void onInput(MaterialDialog dialog, CharSequence input) {
                                    AsyncEventEmail asyncEmail = new AsyncEventEmail(context, "" + input, null,
                                            userProfile, idcmd); // convert charSequence into String object
                                    asyncEmail.execute();
                                }
                            }).show();
                }
            }));

    // Change message
    if (userProfile.isCreated()) {
        tvNothing.setText(getResources().getString(R.string.empty_header_order));
        tvNothing2.setText(getResources().getString(R.string.empty_desc_order));
    } else {
        tvNothing.setText(getResources().getString(R.string.empty_header_noorder));
        tvNothing2.setText(getResources().getString(R.string.empty_desc_noorder));
        tvNothing.setVisibility(View.VISIBLE);
        tvNothing2.setVisibility(View.VISIBLE);
        imgNothing.setVisibility(View.VISIBLE);
        fab.setVisibility(View.GONE);
    }

    // Set data
    mAdapter.setTicketsItems(eventTicketItems);

    // Start update
    if (mHandler == null) {
        mHandler = new android.os.Handler();
        mHandler.postDelayed(updateTimerThread, RUN_START);
    } else {
        mHandler.removeCallbacks(updateTimerThread);
        mHandler.postDelayed(updateTimerThread, RUN_START);
    }

    // Delay to update data
    run = true;

}

From source file:org.cocos2dx.lib.Cocos2dxEditBoxDialog.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);

    getWindow().setBackgroundDrawable(new ColorDrawable(0x80000000));

    LinearLayout layout = new LinearLayout(mParentActivity);
    layout.setOrientation(LinearLayout.VERTICAL);

    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT);

    mTextViewTitle = new TextView(mParentActivity);
    LinearLayout.LayoutParams textviewParams = new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    textviewParams.leftMargin = textviewParams.rightMargin = convertDipsToPixels(10);
    mTextViewTitle.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
    layout.addView(mTextViewTitle, textviewParams);

    mInputEditText = new EditText(mParentActivity);
    LinearLayout.LayoutParams editTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    editTextParams.leftMargin = editTextParams.rightMargin = convertDipsToPixels(10);

    layout.addView(mInputEditText, editTextParams);

    setContentView(layout, layoutParams);

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

    mInputMode = mMsg.inputMode;/*  w w w .  j a va  2 s .  com*/
    mInputFlag = mMsg.inputFlag;
    mReturnType = mMsg.returnType;
    mMaxLength = mMsg.maxLength;

    mTextViewTitle.setText(mMsg.title);
    mInputEditText.setText(mMsg.content);

    int oldImeOptions = mInputEditText.getImeOptions();
    mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
    oldImeOptions = mInputEditText.getImeOptions();

    switch (mInputMode) {
    case kEditBoxInputModeAny:
        mInputModeContraints = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE;
        break;
    case kEditBoxInputModeEmailAddr:
        mInputModeContraints = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;
        break;
    case kEditBoxInputModeNumeric:
        mInputModeContraints = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED;
        break;
    case kEditBoxInputModePhoneNumber:
        mInputModeContraints = InputType.TYPE_CLASS_PHONE;
        break;
    case kEditBoxInputModeUrl:
        mInputModeContraints = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI;
        break;
    case kEditBoxInputModeDecimal:
        mInputModeContraints = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL
                | InputType.TYPE_NUMBER_FLAG_SIGNED;
        break;
    case kEditBoxInputModeSingleLine:
        mInputModeContraints = InputType.TYPE_CLASS_TEXT;
        break;
    default:

        break;
    }

    if (mIsMultiline) {
        mInputModeContraints |= InputType.TYPE_TEXT_FLAG_MULTI_LINE;
    }

    mInputEditText.setInputType(mInputModeContraints | mInputFlagConstraints);

    switch (mInputFlag) {
    case kEditBoxInputFlagPassword:
        mInputFlagConstraints = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD;
        break;
    case kEditBoxInputFlagSensitive:
        mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
        break;
    case kEditBoxInputFlagInitialCapsWord:
        mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_CAP_WORDS;
        break;
    case kEditBoxInputFlagInitialCapsSentence:
        mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_CAP_SENTENCES;
        break;
    case kEditBoxInputFlagInitialCapsAllCharacters:
        mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS;
        break;
    default:
        break;
    }
    mInputEditText.setInputType(mInputFlagConstraints | mInputModeContraints);

    switch (mReturnType) {
    case kKeyboardReturnTypeDefault:
        mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_NONE);
        break;
    case kKeyboardReturnTypeDone:
        mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_DONE);
        break;
    case kKeyboardReturnTypeSend:
        mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_SEND);
        break;
    case kKeyboardReturnTypeSearch:
        mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_SEARCH);
        break;
    case kKeyboardReturnTypeGo:
        mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_GO);
        break;
    default:
        mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_NONE);
        break;
    }

    if (mMaxLength > 0) {
        mInputEditText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(mMaxLength) });
    }

    Handler initHandler = new Handler();
    initHandler.postDelayed(new Runnable() {
        public void run() {
            mInputEditText.requestFocus();
            mInputEditText.setSelection(mInputEditText.length());
            openKeyboard();
        }
    }, 200);

    mInputEditText.setOnEditorActionListener(new OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            // if user didn't set keyboard type,
            // this callback will be invoked twice with 'KeyEvent.ACTION_DOWN' and 'KeyEvent.ACTION_UP'
            if (actionId != EditorInfo.IME_NULL || (actionId == EditorInfo.IME_NULL && event != null
                    && event.getAction() == KeyEvent.ACTION_DOWN)) {
                //Log.d("EditBox", "actionId: "+actionId +",event: "+event);
                mParentActivity.setEditBoxResult(mInputEditText.getText().toString());
                closeKeyboard();
                dismiss();
                return true;
            }
            return false;
        }
    });
}

From source file:com.emobc.android.activities.generators.FormActivityGenerator.java

private EditText insertEmailField(Activity activity, FormDataItem dataItem) {
    EditText txt = insertTextField(activity, dataItem);
    txt.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
    return txt;//  w  ww  .jav  a  2s  .c  o m
}

From source file:com.doodle.android.chips.ChipsView.java

private void init() {
    mDensity = getResources().getDisplayMetrics().density;

    mChipsContainer = new RelativeLayout(getContext());
    addView(mChipsContainer);/*from   ww w. j  a  v a 2s . c  o  m*/

    // Dummy item to prevent AutoCompleteTextView from receiving focus
    LinearLayout linearLayout = new LinearLayout(getContext());
    ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(0, 0);
    linearLayout.setLayoutParams(params);
    linearLayout.setFocusable(true);
    linearLayout.setFocusableInTouchMode(true);

    mChipsContainer.addView(linearLayout);

    mEditText = new ChipsEditText(getContext(), this);
    RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.topMargin = (int) (SPACING_TOP * mDensity);
    layoutParams.bottomMargin = (int) (SPACING_BOTTOM * mDensity) + mVerticalSpacing;
    mEditText.setLayoutParams(layoutParams);
    mEditText.setMinHeight((int) (CHIP_HEIGHT * mDensity));
    mEditText.setPadding(0, 0, 0, 0);
    mEditText.setLineSpacing(mVerticalSpacing, (CHIP_HEIGHT * mDensity) / mEditText.getLineHeight());
    mEditText.setBackgroundColor(Color.argb(0, 0, 0, 0));
    mEditText.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI | EditorInfo.IME_ACTION_UNSPECIFIED);
    mEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS
            | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
    mEditText.setHint(mChipsHintText);

    mChipsContainer.addView(mEditText);

    mRootChipsLayout = new ChipsVerticalLinearLayout(getContext(), mVerticalSpacing);
    mRootChipsLayout.setOrientation(LinearLayout.VERTICAL);
    mRootChipsLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    mRootChipsLayout.setPadding(0, (int) (SPACING_TOP * mDensity), 0, 0);
    mChipsContainer.addView(mRootChipsLayout);

    initListener();

    if (isInEditMode()) {
        // preview chips
        LinearLayout editModeLinLayout = new LinearLayout(getContext());
        editModeLinLayout.setOrientation(LinearLayout.HORIZONTAL);
        mChipsContainer.addView(editModeLinLayout);

        View view = new Chip("Test Chip", null, new Contact(null, null, "Test", "asd@asd.de", null)).getView();
        view.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
                MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
        editModeLinLayout.addView(view);

        View view2 = new Chip("Indelible", null, new Contact(null, null, "Test", "asd@asd.de", null), true)
                .getView();
        view2.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
                MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
        editModeLinLayout.addView(view2);
    }
}