@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); autoComplete = (AutoCompleteTextView)findViewById(R.id.autoComplete); multiComplete = (MultiAutoCompleteTextView)findViewById(R.id.multiAutoComplete); // The lists to be shown to the user. String[] lists = {"Hello-World", "Hello-Thanks", "Hello-Morning", "Bye-World", "Bye-Thanks", "Bye-Morning"}; // To link the data and the view, we should use 'Adapter'. ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, lists); // Link the adapter above to the view. autoComplete.setAdapter(adapter); // Set the tokenizer for the multiComplete. multiComplete.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer()); multiComplete.setAdapter(adapter); }
private void saveActivityState() { MultiAutoCompleteTextView taskTextEditText = (MultiAutoCompleteTextView) findViewById(R.id.task_text_edit_text); if (taskTextEditText != null) { String taskText = taskTextEditText.getText().toString(); if (!taskText.equals("")) { String[] state = new String[]{ taskText, mTeam, mDoneDate }; Utils.setNewTaskActivityState(this, state); //Log.i(LOG_TAG, "Saved: " + state[0] + ", " + state[1]); } else Utils.clearNewTaskActivityState(this); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); String mAction = getIntent().getAction(); getToolbar().setTitle(mAction + getString(R.string.activity_create_title_suffix)); boolean isEdit = false; if (mAction != null) { isEdit = mAction.equals(Consts.MESSAGE_EDIT); } mContact.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer()); BaseRecipientAdapter adapter = new BaseRecipientAdapter( BaseRecipientAdapter.QUERY_TYPE_PHONE, this); adapter.setShowMobileOnly(true); mContact.setAdapter(adapter); mContact.dismissDropDownOnItemSelected(true); if (isEdit) { mMessageId = getIntent().getExtras().getLong(Consts.KEY_MESSAGE_ID); Message message = Message.findById(Message.class, mMessageId); populate(message); } else { setDate(new Date()); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.appcompat_widgets_text_input); // Fetch the AutoCompleteTextView and set an adapter AutoCompleteTextView actv = (AutoCompleteTextView) findViewById( R.id.widgets_autocompletetextview); actv.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_dropdown_item_1line, Cheeses.sCheeseStrings)); // Fetch the MultiAutoCompleteTextView and set an adapter and Tokenizer MultiAutoCompleteTextView mactv = (MultiAutoCompleteTextView) findViewById( R.id.widgets_multiautocompletetextview); mactv.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer()); mactv.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_dropdown_item_1line, Cheeses.sCheeseStrings)); }
@SuppressWarnings("unchecked") @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch(requestCode) { case Constants.REQUEST_CODE_USER_SELECTOR: if (resultCode == Constants.RESULT_CODE_SUCCESS) { List<User> userList = (List<User>)data.getSerializableExtra("LIST_USER"); if (ListUtil.isEmpty(userList)) { userList = new ArrayList<User>(); } MultiAutoCompleteTextView etText = (MultiAutoCompleteTextView)this.findViewById(R.id.etText); StringBuilder mentions = new StringBuilder(""); for (User user : userList) { mentions.append(user.getMentionName()).append(" "); } int currentPos = etText.getSelectionStart(); etText.getText().insert(currentPos, mentions); } break; default: break; } }
private MultiAutoCompleteTextView initMultiAutoCompleteTextView(RecipientEditTextView list) { if (ChipsUtil.supportsChipsUi()) { mAddressAdapter = new RecipientAdapter(mActivity); list.setAdapter((BaseRecipientAdapter) mAddressAdapter); list.setOnFocusListShrinkRecipients(false); } else { mAddressAdapter = new EmailAddressAdapter(mActivity); list.setAdapter((EmailAddressAdapter)mAddressAdapter); } list.setTokenizer(new Rfc822Tokenizer()); list.setValidator(mEmailValidator); // NOTE: assumes no other filters are set list.setFilters(sRecipientFilters); return list; }
protected void setTextInTextViews(Location selectedItem) { if (plan.getFrom() != null) { // for(Location l : plan.getFrom()) for (MultiAutoCompleteTextView view : textViews) { if (view.getText().toString().length() > 0 && !doesPlanContainthis(view.getText().toString())) { view.setText(selectedItem.getDisplayname()); break; } } } else { textViews.get(0).setText(selectedItem.getDisplayname()); } }
private int plannerSameSizeAsTextViews() { int plancount = 0; int textViewCount = 0; if (plan.getFrom() != null) plancount = plan.getFrom().size(); for (MultiAutoCompleteTextView textView : textViews) { if (!textView.getText().toString().isEmpty()) textViewCount++; } if (plancount == textViewCount) return 0; else if (plancount > textViewCount) return -1; else return 1; }
public static void setupAccountHistory( AutoCompleteTextView... autoTextViewArray ) { for ( AutoCompleteTextView actv : autoTextViewArray ) { AccountAdapter adapter = new AccountAdapter(actv.getContext(), R.layout.account_suggestion, R.id.eos_account); if (actv instanceof MultiAutoCompleteTextView) { ((MultiAutoCompleteTextView) actv).setTokenizer(new WhitSpaceTokenizer()); } actv.setThreshold(1); actv.setAdapter(adapter); } }
RecipientsEditorTokenizer(Context context, MultiAutoCompleteTextView list) { mInflater = LayoutInflater.from(context); mList = list; final int size = android.R.style.TextAppearance_Small; final int color = 8;//android.R.styleable.Theme_textColorSecondary; mLabelSpan = new TextAppearanceSpan(context, size, color); mTypeSpan = new TextAppearanceSpan(context, size, color); }
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); this.mRecyclerView = (RecyclerView) view.findViewById(R.id.cp_listView); this.mNachoTextView = (NachoTextView) view.findViewById(R.id.nachoTextView); this.mNachoTextView.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer()); this.mNachoTextView.setThreshold(3); this.mNachoTextView.setMaxLines(2); this.mNachoTextView.addChipTerminator(' ', ChipTerminatorHandler.BEHAVIOR_CHIPIFY_TO_TERMINATOR); this.mNachoTextView.setChipTokenizer(new SpanChipTokenizer<>(getContext(), new ContactChipCreator(), ChipSpan.class)); }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the diet_raw_layout for this fragment ViewGroup rootView = (ViewGroup)inflater.inflate(R.layout.fragment_settings, container, false); // Inflate the diet_raw_layout for this fragment lv = (ListView) rootView.findViewById(R.id.ingr_listviewSett); lv2 = (ListView) rootView.findViewById(R.id.dietListSett); calorieSeekBar = (RangeSeekBar<Integer>) rootView.findViewById(R.id.seekbarForCalorieSett); calorieSeekBar.setOnRangeSeekBarChangeListener(seekBarChnaged()); fatSeekBar = (RangeSeekBar<Integer>) rootView.findViewById(R.id.seekBarForFatSett); fatSeekBar.setOnRangeSeekBarChangeListener(seekBarChnaged()); proSeekBar = (RangeSeekBar<Integer>) rootView.findViewById(R.id.rangeSeekBarForProSett); proSeekBar.setOnRangeSeekBarChangeListener(seekBarChnaged()); carbSeekBar = (RangeSeekBar<Integer>) rootView.findViewById(R.id.seekBarForCabSett); carbSeekBar.setOnRangeSeekBarChangeListener(seekBarChnaged()); mtext1 = (MultiAutoCompleteTextView)rootView.findViewById(R.id.multiAutoCompleteTextView1Sett); saveBut = (Button) rootView.findViewById(R.id.saveDietSett); name = (EditText) rootView.findViewById(R.id.editTextNameSett); descr = (EditText)rootView.findViewById(R.id.editTextDescSett); return rootView; }
/** * Initialize a presenter for sandbox * * @param activity Activity that hosts this sandbox * @param rootView Root view of the sandbox * @param overlayInflater Overlay inflater used to inflate rhythm config */ public RhythmSandbox(AppCompatActivity activity, View rootView, RhythmOverlayInflater overlayInflater) { mActivity = activity; mOverlayInflater = overlayInflater; // Find and init preview layout mPreview = (RhythmFrameLayout) rootView.findViewById(R.id.preview); mPreview.setRhythmDrawable(new RhythmDrawable(null)); // Find and init overlay config text box mOverlayConfig = (MultiAutoCompleteTextView) rootView.findViewById(R.id.config); mOverlayConfig.setHorizontallyScrolling(true); // Fix config text box metrics int i4dp = activity.getResources().getDimensionPixelOffset(R.dimen.i4dp); Utils.setExactMetrics(mOverlayConfig, i4dp * 6, i4dp * 5, i4dp * 3); // Enable auto-complete for config ArrayAdapter<String> adapter = new ArrayAdapter<>(activity, android.R.layout.simple_dropdown_item_1line, ALL_CONFIG_WORDS); mOverlayConfig.setTokenizer(new ConfigTokenizer()); mOverlayConfig.setAdapter(adapter); // Find and init Apply button final Button applyButton = (Button) rootView.findViewById(R.id.apply); applyButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { updatePreview(); } }); }
private void addAddresses(MultiAutoCompleteTextView view, String addresses) { if (StringUtils.isNullOrEmpty(addresses)) { return; } for (String address : addresses.split(",")) { addAddress(view, new Address(address, "")); } }
private void addAddresses(MultiAutoCompleteTextView view, Address[] addresses) { if (addresses == null) { return; } for (Address address : addresses) { addAddress(view, address); } }
private void init(Context context) { mContext = (QKActivity) context; mAdapter = new BaseRecipientAdapter(BaseRecipientAdapter.QUERY_TYPE_PHONE, getContext()); setThreshold(1); setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer()); setAdapter(mAdapter); setOnItemClickListener(this); LiveViewManager.registerView(QKPreference.FONT_FAMILY, this, key -> { setTypeface(FontManager.getFont(mContext)); }); LiveViewManager.registerView(QKPreference.FONT_WEIGHT, this, key -> { setTypeface(FontManager.getFont(mContext)); }); LiveViewManager.registerView(QKPreference.FONT_SIZE, this, key -> { setTextSize(TypedValue.COMPLEX_UNIT_SP, FontManager.getTextSize(mContext, FontManager.TEXT_TYPE_PRIMARY)); }); LiveViewManager.registerView(QKPreference.BACKGROUND, this, key -> { setTextColor(ThemeManager.getTextOnBackgroundPrimary()); setHintTextColor(ThemeManager.getTextOnBackgroundSecondary()); }); LiveViewManager.registerView(QKPreference.MOBILE_ONLY, this, key -> { if (mAdapter != null) { SharedPreferences prefs1 = mContext.getPrefs(); mAdapter.setShowMobileOnly(prefs1.getBoolean(SettingsFragment.MOBILE_ONLY, false)); } }); }
@Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_invite_collaborators, container, false); mFilterTerm = ""; mRoleButton = (Button) view.findViewById(R.id.invite_collaborator_role); mRoleButton.setOnClickListener(this); mAutoComplete = (ChipCollaborationView) view.findViewById(R.id.invite_collaborator_autocomplete); mAutoComplete.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer()); mAdapter = createInviteeAdapter(getActivity()); mAdapter.setInviteeAdapterListener(this); mAutoComplete.setAdapter(mAdapter); mAutoComplete.setTokenListener(this); mCollabInitialsView = (CollaboratorsInitialsView) view.findViewById(R.id.collaboratorsInitialsView); mCollabInitialsView.setArguments((BoxCollaborationItem)mShareItem, mController); // Get serialized roles or fetch them if they are not available if (getCollaborationItem() != null && getCollaborationItem().getAllowedInviteeRoles() != null) { if(getCollaborationItem().getPermissions().contains(BoxItem.Permission.CAN_INVITE_COLLABORATOR)) { mRoles = getCollaborationItem().getAllowedInviteeRoles(); BoxCollaboration.Role selectedRole = mRoles.get(0); setSelectedRole(selectedRole); } else { showNoPermissionToast(); getActivity().finish(); } } else { fetchRoles(); } fetchInvitees(); if (getArguments().getBoolean(EXTRA_USE_CONTACTS_PROVIDER)){ requestPermissionsIfNecessary(); } return view; }
/** * Returns the default style attribute depending on the view class. * <p> * Order matters: a {@link CheckBox} is also {@link Button}, so we have to be careful when returning the default * style attribute. */ @SuppressLint({"InlinedApi", "PrivateResource"}) protected int getDefaultViewDefStyleAttr(View view) { if (view instanceof RadioButton) { return android.R.attr.radioButtonStyle; } else if (view instanceof CheckBox) { return android.R.attr.checkboxStyle; } else if (view instanceof Button) { return android.R.attr.buttonStyle; } else if (view instanceof MultiAutoCompleteTextView) { return android.R.attr.autoCompleteTextViewStyle; } else if (view instanceof AutoCompleteTextView) { return android.R.attr.autoCompleteTextViewStyle; } else if (view instanceof EditText) { return android.R.attr.editTextStyle; } else if (view instanceof CheckedTextView) { return Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 ? android.R.attr.checkedTextViewStyle : 0; } else if (view instanceof TextView) { return android.R.attr.textViewStyle; } else if (view instanceof Spinner) { return android.R.attr.spinnerStyle; } else if (view instanceof ImageButton) { return android.R.attr.imageButtonStyle; } else if (view instanceof RatingBar) { return android.R.attr.ratingBarStyle; } else if (view instanceof SeekBar) { return android.R.attr.seekBarStyle; } else { return 0; } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.autocomplete_6); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, COUNTRIES); MultiAutoCompleteTextView textView = (MultiAutoCompleteTextView) findViewById(R.id.edit); textView.setAdapter(adapter); textView.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer()); }
public AutoCompleteWrapper(final MultiAutoCompleteTextView textView, Context context) { this.a_textView = textView; this.a_context = context; this.a_textView.setTokenizer(new SpaceTokenizer()); this.adapter = new ArrayAdapter<>(a_context, R.layout.tags_list); this.a_textView.setAdapter(this.adapter); this.a_textView.setThreshold(1); updateTagsView(); AutoCompleteRetriever task = new AutoCompleteRetriever(); task.execute(); }
@SuppressWarnings("unchecked") @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch(requestCode) { case Constants.REQUEST_CODE_IMG_SELECTOR: case Constants.REQUEST_CODE_CAMERA: break; case Constants.REQUEST_CODE_USER_SELECTOR: if (resultCode == Constants.RESULT_CODE_SUCCESS) { List<User> userList = (List<User>)data.getSerializableExtra("LIST_USER"); if (ListUtil.isEmpty(userList)) { userList = new ArrayList<User>(); } MultiAutoCompleteTextView etText = (MultiAutoCompleteTextView)this.findViewById(R.id.etText); StringBuilder mentions = new StringBuilder(); for (User user : userList) { mentions.append(user.getMentionName()).append(" "); } int currentPos = etText.getSelectionStart(); etText.getText().insert(currentPos, mentions); } break; default: break; } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mApp = (ImApp)getApplication(); mHandler = new SimpleAlertHandler(this); resolveIntent(getIntent()); setContentView(R.layout.add_contact_activity); BrandingResources brandingRes = mApp.getBrandingResource(mProviderId); setTitle(brandingRes.getString(BrandingResourceIDs.STRING_ADD_CONTACT_TITLE)); TextView label = (TextView) findViewById(R.id.input_contact_label); label.setText(brandingRes.getString(BrandingResourceIDs.STRING_LABEL_INPUT_CONTACT)); mAddressList = (MultiAutoCompleteTextView) findViewById(R.id.email); mAddressList.setAdapter(new EmailAddressAdapter(this)); mAddressList.setTokenizer(new Rfc822Tokenizer()); mAddressList.addTextChangedListener(mTextWatcher); mListSpinner = (Spinner) findViewById(R.id.choose_list); Cursor c = queryContactLists(); int initSelection = searchInitListPos(c, getIntent().getStringExtra(ImServiceConstants.EXTRA_INTENT_LIST_NAME)); SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item, c, new String[] { Imps.ContactList.NAME }, new int[] { android.R.id.text1 }); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mListSpinner.setAdapter(adapter); mListSpinner.setSelection(initSelection); mInviteButton = (Button) findViewById(R.id.invite); mInviteButton.setText(brandingRes.getString(BrandingResourceIDs.STRING_BUTTON_ADD_CONTACT)); mInviteButton.setOnClickListener(mButtonHandler); mInviteButton.setEnabled(false); }
private void enableButton() { int containing = 0; for (MultiAutoCompleteTextView view : textViews) { if (!view.getText().toString().isEmpty()) containing++; } if (autoTo.getText().toString().isEmpty()) { okbutton.setEnabled(false); return; } if (containing > 0) { okbutton.setEnabled(true); } else okbutton.setEnabled(false); }
private MultiAutoCompleteTextView getTextWithoutPlan() { if (plan.getTo() == null || !plan.getTo().getDisplayname() .equals(autoTo.getText().toString())) return autoTo; if (plan.getFrom() == null) return textViews.get(0); else { for (int i = 0; i < plan.getFrom().size(); i++) { String text = textViews.get(i).getText().toString(); String planText = plan.getFrom().get(i).getDisplayname(); if (!text.equals(planText)) return textViews.get(i); } for (int i = 0; i < textViews.size(); i++) { if (textViews.get(i).getText().toString().length() > 0) { if (i > (plan.getFrom().size() - 1)) return textViews.get(i); else if (plan.getFrom().get(i).getDisplayname() .equals(textViews.get(i).getText().toString())) continue; else return textViews.get(i); } } } return null; }
private MultiAutoCompleteTextView createNewMultiCompleteTextView() { MultiAutoCompleteTextView view = new MultiAutoCompleteTextView( getActivity()); view.setLayoutParams(textViews.get(0).getLayoutParams()); view.setAdapter(adapter); setupTextViewDropdowns(view); view.setHint(getActivity().getString(R.string.from)); textViews.add(view); setupImeTypesAndListner(view); setupfocusCHangeListener(view); return view; }
private void setupfocusCHangeListener(MultiAutoCompleteTextView view) { view.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { // TODO Auto-generated method stub if (hasFocus) ScrollToView(v); } }); }
private void setupTextBody () { this.txtBody = (MultiAutoCompleteTextView) findViewById(R.id.txtBody); final TextView txtCharRemaining = (TextView) findViewById(R.id.txtCharRemaining); this.txtBody.addTextChangedListener(new TextCounterWatcher(txtCharRemaining, this.txtBody)); if (Intent.ACTION_SEND.equals(getIntent().getAction()) && "text/plain".equals(getIntent().getType())) { final String intentText = getIntent().getStringExtra(Intent.EXTRA_TEXT); if (intentText != null) { this.txtBody.setText(intentText); this.txtBody.setSelection(this.txtBody.getText().length()); } } }
private void populateContactSearch() { List<String> contacts = new ArrayList<String>(); ContentResolver cr = this.getContentResolver(); Cursor cursor = cr.query(ContactsContract.Contacts.CONTENT_URI, CONTACT_COLUMNS, null, null, null); while (cursor.moveToNext()) { String name = cursor.getString(0); contacts.add(name); } cursor.close(); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.contact_list_item, contacts.toArray(new String[] {})); MultiAutoCompleteTextView txtFriends = (MultiAutoCompleteTextView) findViewById(R.id.newVisitFriends); txtFriends.setAdapter(adapter); txtFriends.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer()); }
RecipientsEditorTokenizer(Context context, MultiAutoCompleteTextView list) { mList = list; mContext = context; }
/** * Sets the Tokenizer that will be used to determine the relevant * range of the text where the user is typing. * <p>Only work when autoCompleMode is AUTOCOMPLETE_MODE_MULTI</p> */ public void setTokenizer(MultiAutoCompleteTextView.Tokenizer t) { if(mAutoCompleteMode != AUTOCOMPLETE_MODE_MULTI) return; ((MultiAutoCompleteTextView)mInputView).setTokenizer(t); }