List of usage examples for android.text InputType TYPE_CLASS_PHONE
int TYPE_CLASS_PHONE
To view the source code for android.text InputType TYPE_CLASS_PHONE.
Click Source Link
From source file:com.liato.bankdroid.banking.banks.Bredband2VoIP.java
public Bredband2VoIP(Context context) { super(context); TAG = "Bredband2VoIP"; NAME = "Bredband2 VoIP"; NAME_SHORT = "bredband2voip"; BANKTYPE_ID = IBankTypes.BREDBAND2VOIP; super.INPUT_TYPE_USERNAME = InputType.TYPE_CLASS_PHONE; super.INPUT_HINT_USERNAME = "19XXXXXX-XXXX"; }
From source file:foo.fruitfox.evend.LoginActivity.java
private void setLayout(String type, LinearLayout activityLayout) { login = (Button) findViewById(R.id.login); register = (Button) findViewById(R.id.register); username = (EditText) findViewById(R.id.username); usernameLabel = (TextView) findViewById(R.id.usernameLabel); switch (type) { case "phone": username.setInputType(InputType.TYPE_CLASS_PHONE); username.setText(getPhoneNumber()); usernameLabel.setText("Phone Number"); login.setVisibility(View.GONE); register.setVisibility(View.VISIBLE); break;//from w w w . ja v a 2 s. co m case "email": username.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS); // TODO: Remove this Hardcoding username.setText("john@example.com"); usernameLabel.setText("E-Mail"); login.setVisibility(View.GONE); register.setVisibility(View.VISIBLE); break; } setContentView(activityLayout); }
From source file:com.android.messaging.ui.appsettings.PhoneNumberPreference.java
@Override protected void onBindDialogView(final View view) { super.onBindDialogView(view); final String value = getText(); // If the preference is empty, populate the EditText with the default number instead. if (TextUtils.isEmpty(value) && !TextUtils.isEmpty(mDefaultPhoneNumber)) { final BidiFormatter bidiFormatter = BidiFormatter.getInstance(); final String phoneNumber = bidiFormatter.unicodeWrap( PhoneUtils.get(mSubId).getCanonicalBySystemLocale(mDefaultPhoneNumber), TextDirectionHeuristicsCompat.LTR); getEditText().setText(phoneNumber); }//ww w . j av a2s .c o m getEditText().setInputType(InputType.TYPE_CLASS_PHONE); }
From source file:com.github.chilinh.androidformbuilder.MainFragment.java
private void showDialog() { AlertDialog dialog = new Form.Builder().title("Edit Info").addSection(new SectionElement("Personal")) .addElement(new EditTextElement(null, "Name:").placeholder("Your name here").required(true) .labelTypeface(Typeface.BOLD)) .addElement(new ComboBoxElement(null, "Genre", "", "Male", "Female")) .addElement(new TextElement(null, "For you:").placeholder("N/A").labelTypeface(Typeface.BOLD)) .addElement(new EditTextElement(null, null).placeholder("Phone number here") .setInputTypeMask(InputType.TYPE_CLASS_PHONE, true).required(true)) .addSection(new SectionElement("More")) .addElement(new DatePickerElement(null, "Birthday: ").date(Calendar.getInstance().getTime())) .addElement(new TimePickerElement(null, "Leave: ").time(Calendar.getInstance().getTime())) .build(getContext()).buildDialog(getContext(), null, null); dialog.show();/*from ww w . j a v a 2s . c om*/ }
From source file:edu.rosehulman.grocerydroid.ItemDialogFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.fragment_dialog_item, container, false); // EditText nameBox = (EditText) view.findViewById(R.id.item_name_box); AutoCompleteTextView nameBox = (AutoCompleteTextView) view.findViewById(R.id.item_name_box); nameBox.setInputType(InputType.TYPE_TEXT_FLAG_CAP_WORDS); // String[] names = new String[] { "Bob", "Joe", "Caleb", "Jonathan", // "Elise" }; String[] foodNames = getResources().getStringArray(R.array.food_names); // ArrayAdapter<String> autoAdapter = new ArrayAdapter<String>( // getActivity(), android.R.layout.simple_list_item_1, names); ArrayAdapter<String> autoAdapter = new ArrayAdapter<String>(getActivity(), R.layout.dropdown_item, foodNames);//from w w w.j a v a2 s .c o m // android.R.layout.sherlock.* both white/invisible // android.R.layout. // simple_spinner_item too thin // simple list item 2: crash // activity_list_item crash //simple_spinner_dropdown_item nameBox.setAdapter(autoAdapter); // mEditIcon.setOnKeyListener(new OnKeyListener() { // @Override // public boolean onKey(View v, int keyCode, KeyEvent event) { // // If the event is a key-down event on the "enter" button // if ((event.getAction() == KeyEvent.ACTION_DOWN) // && (keyCode == KeyEvent.KEYCODE_ENTER)) { // Toast.makeText(StockActivity.this, tv.getText(), // Toast.LENGTH_SHORT).show(); // return true; // } // return false; // } // }); EditText priceBox = (EditText) view.findViewById(R.id.item_price_box); priceBox.setInputType(InputType.TYPE_CLASS_PHONE); // priceBox.setInputType(InputType.TYPE_CLASS_NUMBER|InputType.TYPE_NUMBER_FLAG_DECIMAL); // first true : is signed, second one : is decimal priceBox.setKeyListener(new DigitsKeyListener(false, true)); EditText sizeBox = (EditText) view.findViewById(R.id.item_unit_size_box); sizeBox.setText("" + mItem.getUnitSize()); Spinner unitSpinner = (Spinner) view.findViewById(R.id.item_unit_label_spinner); ArrayAdapter<Item.UnitLabel> adapter; adapter = new ArrayAdapter<Item.UnitLabel>(this.getActivity(), android.R.layout.simple_spinner_item, Item.UnitLabel.values()); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); unitSpinner.setAdapter(adapter); EditText numStockBox = (EditText) view.findViewById(R.id.item_num_stock); numStockBox.setText("" + mItem.getNStock()); // If this activity was started with the purpose of editing an existing // item, then we use the item passed in the intent to populate the // spinners and edit text boxes. if (!mItem.getName().equals("")) { // TODO Make non-focusable, non-touchable so it doesn't kick off the drop down. // But it doesn't work! nameBox.setFocusable(false); nameBox.setFocusableInTouchMode(false); nameBox.setText(mItem.getName()); // Reset the focus & touch nameBox.setFocusable(true); nameBox.setFocusableInTouchMode(true); priceBox.setText(Float.toString(mItem.getPrice())); unitSpinner.setSelection(mItem.getUnitLabel().ordinal()); } Button incrementNumStockButton = (Button) view.findViewById(R.id.item_increment_num_stock); incrementNumStockButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { EditText et = (EditText) view.findViewById(R.id.item_num_stock); int numStock = getIntegerFromEditText(et); numStock++; et.setText(numStock + ""); } }); Button decrementNumStockButton = (Button) view.findViewById(R.id.item_decrement_num_stock); decrementNumStockButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { EditText et = (EditText) view.findViewById(R.id.item_num_stock); int numStock = getIntegerFromEditText(et); numStock--; et.setText(numStock + ""); } }); Button saveButton = (Button) view.findViewById(R.id.item_save_button); saveButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { EditText et = (EditText) view.findViewById(R.id.item_name_box); String name = et.getText().toString(); et = (EditText) view.findViewById(R.id.item_price_box); float price = getFloatFromEditText(et); et = (EditText) view.findViewById(R.id.item_unit_size_box); float size = getFloatFromEditText(et); Spinner spinner = (Spinner) view.findViewById(R.id.item_unit_label_spinner); int unitIndex = spinner.getSelectedItemPosition(); et = (EditText) view.findViewById(R.id.item_num_stock); int numStock = getIntegerFromEditText(et); mItem = new Item(mItem.getId(), mItem.getListId(), name, numStock, mItem.getNBuy(), price, size, Item.UnitLabel.values()[unitIndex], mItem.isBought(), mItem.getStockIdx(), mItem.getShopIdx()); if (mMode == Mode.ADD) { ((ShoppingListActivity) getActivity()).addItem(mItem); } else if (mMode == Mode.EDIT) { ((ShoppingListActivity) getActivity()).updateItem(mItem); } else { // shouldn't get here. } dismiss(); } }); Button cancelButton = (Button) view.findViewById(R.id.item_cancel_button); cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dismiss(); } }); Button deleteButton = (Button) view.findViewById(R.id.item_delete_button); deleteButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mMode == Mode.EDIT) { ConfirmDeleteItemDialogFragment df = new ConfirmDeleteItemDialogFragment(); df.setItem(mItem); df.show(getActivity().getSupportFragmentManager(), "confirm"); } // Otherwise, we are adding this item, so we don't need to // delete it. // TODO: Remove modes altogether once autocomplete works, since // every item here will exist and be beging added. // CONSIDER: at that point, I will need to make sure that items // that have a name only (from autocomplete) have been saved in // the DB // and have a unique ID so they can be deleted. dismiss(); } }); return view; }
From source file:ru.orangesoftware.financisto.widget.AmountInput.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { requestId = EDIT_AMOUNT_REQUEST.incrementAndGet(); LinearLayout v = new LinearLayout(getActivity()); v.setOrientation(LinearLayout.HORIZONTAL); LinearLayout.LayoutParams lpWrapWrap = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);/*w w w . j a v a2s . c om*/ lpWrapWrap.weight = 1; inflater.inflate(R.layout.amount_input, v, true); c = new Controls(v); c.AmountInput.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), QuickAmountInput.class); intent.putExtra(EXTRA_AMOUNT, getAbsAmountString()); startActivityForResult(intent, requestId); } }); c.CalculatorInput.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), CalculatorInput.class); intent.putExtra(EXTRA_AMOUNT, getAbsAmountString()); startActivityForResult(intent, requestId); } }); c.primary.setKeyListener(keyListener); c.primary.addTextChangedListener(textWatcher); c.primary.setOnFocusChangeListener(selectAllOnFocusListener); c.secondary.setKeyListener(new DigitsKeyListener(false, false) { @Override public boolean onKeyDown(View view, Editable content, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_DEL) { if (content.length() == 0) { c.primary.requestFocus(); int pos = c.primary.getText().length(); c.primary.setSelection(pos, pos); return true; } } return super.onKeyDown(view, content, keyCode, event); } @Override public int getInputType() { return InputType.TYPE_CLASS_PHONE; } }); c.secondary.addTextChangedListener(textWatcher); c.secondary.setOnFocusChangeListener(selectAllOnFocusListener); return v; }
From source file:com.tingtingapps.securesms.ContactSelectionActivity.java
private void initializeResources() { this.action = (ImageView) findViewById(R.id.action_icon); this.searchText = (EditText) findViewById(R.id.search_view); this.toggle = (AnimatingToggle) findViewById(R.id.button_toggle); this.keyboardToggle = (ImageView) findViewById(R.id.search_keyboard); this.dialpadToggle = (ImageView) findViewById(R.id.search_dialpad); this.clearToggle = (ImageView) findViewById(R.id.search_clear); this.toggleContainer = (LinearLayout) findViewById(R.id.toggle_container); contactsFragment = (ContactSelectionListFragment) getSupportFragmentManager() .findFragmentById(R.id.contact_selection_list_fragment); contactsFragment.setOnContactSelectedListener(this); contactsFragment.setOnRefreshListener(this); this.keyboardToggle.setOnClickListener(new View.OnClickListener() { @Override/*from www. j av a 2s. c o m*/ public void onClick(View v) { searchText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PERSON_NAME); ServiceUtil.getInputMethodManager(ContactSelectionActivity.this).showSoftInput(searchText, 0); displayTogglingView(dialpadToggle); } }); this.dialpadToggle.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { searchText.setInputType(InputType.TYPE_CLASS_PHONE); ServiceUtil.getInputMethodManager(ContactSelectionActivity.this).showSoftInput(searchText, 0); displayTogglingView(keyboardToggle); } }); this.clearToggle.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { searchText.setText(""); if (SearchUtil.isTextInput(searchText)) displayTogglingView(dialpadToggle); else displayTogglingView(keyboardToggle); } }); expandTapArea(toolbar, action, 500); expandTapArea(toggleContainer, dialpadToggle, 500); }
From source file:eu.hydrologis.geopaparazzi.maptools.FeaturePageAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { final Feature feature = featuresList.get(position); int bgColor = context.getResources().getColor(R.color.formbgcolor); int textColor = context.getResources().getColor(R.color.formcolor); ScrollView scrollView = new ScrollView(context); ScrollView.LayoutParams scrollLayoutParams = new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);//from w ww . j av a 2 s . c o m scrollLayoutParams.setMargins(10, 10, 10, 10); scrollView.setLayoutParams(scrollLayoutParams); scrollView.setBackgroundColor(bgColor); LinearLayout linearLayoutView = new LinearLayout(context); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); int margin = 10; layoutParams.setMargins(margin, margin, margin, margin); linearLayoutView.setLayoutParams(layoutParams); linearLayoutView.setOrientation(LinearLayout.VERTICAL); int padding = 10; linearLayoutView.setPadding(padding, padding, padding, padding); scrollView.addView(linearLayoutView); List<String> attributeNames = feature.getAttributeNames(); List<String> attributeValues = feature.getAttributeValuesStrings(); List<String> attributeTypes = feature.getAttributeTypes(); for (int i = 0; i < attributeNames.size(); i++) { final String name = attributeNames.get(i); String value = attributeValues.get(i); String typeString = attributeTypes.get(i); DataType type = DataType.getType4Name(typeString); TextView textView = new TextView(context); textView.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); textView.setPadding(padding, padding, padding, padding); textView.setText(name); textView.setTextColor(textColor); // textView.setTextAppearance(context, android.R.style.TextAppearance_Medium); linearLayoutView.addView(textView); final EditText editView = new EditText(context); LinearLayout.LayoutParams editViewParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); editViewParams.setMargins(margin, 0, margin, 0); editView.setLayoutParams(editViewParams); editView.setPadding(padding * 2, padding, padding * 2, padding); editView.setText(value); // editView.setEnabled(!isReadOnly); editView.setFocusable(!isReadOnly); // editView.setTextAppearance(context, android.R.style.TextAppearance_Medium); if (isReadOnly) { editView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { String text = editView.getText().toString(); FeatureUtilities.viewIfApplicable(v.getContext(), text); return false; } }); } switch (type) { case DOUBLE: case FLOAT: editView.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); break; case PHONE: editView.setInputType(InputType.TYPE_CLASS_PHONE); break; case DATE: editView.setInputType(InputType.TYPE_CLASS_DATETIME); break; case INTEGER: editView.setInputType(InputType.TYPE_CLASS_NUMBER); break; default: break; } editView.addTextChangedListener(new TextWatcher() { public void onTextChanged(CharSequence s, int start, int before, int count) { // ignore } public void beforeTextChanged(CharSequence s, int start, int count, int after) { // ignore } public void afterTextChanged(Editable s) { String text = editView.getText().toString(); feature.setAttribute(name, text); } }); linearLayoutView.addView(editView); } /* * add also area and length */ if (feature.getOriginalArea() > -1) { TextView areaTextView = new TextView(context); areaTextView.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); areaTextView.setPadding(padding, padding, padding, padding); areaTextView.setText("Area: " + areaLengthFormatter.format(feature.getOriginalArea())); areaTextView.setTextColor(textColor); TextView lengthTextView = new TextView(context); lengthTextView.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); lengthTextView.setPadding(padding, padding, padding, padding); lengthTextView.setText("Length: " + areaLengthFormatter.format(feature.getOriginalLength())); lengthTextView.setTextColor(textColor); linearLayoutView.addView(areaTextView); linearLayoutView.addView(lengthTextView); } container.addView(scrollView); return scrollView; }
From source file:net.kourlas.voipms_sms.activities.NewConversationActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { switch (item.getItemId()) { case R.id.keyboard_button: SearchView searchView = (SearchView) actionBar.getCustomView().findViewById(R.id.search_view); if (searchView.getInputType() == (InputType.TYPE_TEXT_VARIATION_PERSON_NAME)) { searchView.setInputType(InputType.TYPE_CLASS_PHONE); item.setIcon(R.drawable.ic_keyboard_white_24dp); item.setTitle(R.string.new_conversation_action_keyboard); } else { searchView.setInputType(InputType.TYPE_TEXT_VARIATION_PERSON_NAME); item.setIcon(R.drawable.ic_dialpad_white_24dp); item.setTitle(R.string.new_conversation_action_dialpad); }/*from w w w . ja v a 2 s . co m*/ return true; } } return super.onOptionsItemSelected(item); }
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();//ww w. ja v a 2 s .com setupFontFamily(); }