本文整理匯總了Java中android.widget.MultiAutoCompleteTextView.setAdapter方法的典型用法代碼示例。如果您正苦於以下問題:Java MultiAutoCompleteTextView.setAdapter方法的具體用法?Java MultiAutoCompleteTextView.setAdapter怎麽用?Java MultiAutoCompleteTextView.setAdapter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.MultiAutoCompleteTextView
的用法示例。
在下文中一共展示了MultiAutoCompleteTextView.setAdapter方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreate
import android.widget.MultiAutoCompleteTextView; //導入方法依賴的package包/類
@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);
}
示例2: onCreate
import android.widget.MultiAutoCompleteTextView; //導入方法依賴的package包/類
@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));
}
示例3: RhythmSandbox
import android.widget.MultiAutoCompleteTextView; //導入方法依賴的package包/類
/**
* 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();
}
});
}
示例4: onCreate
import android.widget.MultiAutoCompleteTextView; //導入方法依賴的package包/類
@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());
}
示例5: onCreate
import android.widget.MultiAutoCompleteTextView; //導入方法依賴的package包/類
@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);
}
示例6: createNewMultiCompleteTextView
import android.widget.MultiAutoCompleteTextView; //導入方法依賴的package包/類
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;
}
示例7: populateContactSearch
import android.widget.MultiAutoCompleteTextView; //導入方法依賴的package包/類
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());
}
示例8: handleIntent
import android.widget.MultiAutoCompleteTextView; //導入方法依賴的package包/類
/**
* Handle {@link Intent}.
*
* @param intent {@link Intent}
*/
@SuppressWarnings("deprecation")
private void handleIntent(final Intent intent) {
if (parseIntent(intent)) {
setTheme(android.R.style.Theme_Translucent_NoTitleBar);
send();
finish();
} else {
int tid = getThreadId();
if (tid >= 0) {
Intent i = new Intent(Intent.ACTION_VIEW, Uri.withAppendedPath(
ConversationListActivity.URI, String.valueOf(tid)), this,
MessageListActivity.class);
i.putExtra("showKeyboard", true);
startActivity(i);
finish();
} else {
setTheme(PreferencesActivity.getTheme(this));
setContentView(R.layout.sender);
findViewById(R.id.text_paste).setOnClickListener(this);
final EditText et = (EditText) findViewById(R.id.text);
et.addTextChangedListener(new MyTextWatcher(this, (TextView) this
.findViewById(R.id.text_paste), (TextView) findViewById(R.id.text_)));
et.setText(text);
final MultiAutoCompleteTextView mtv = (MultiAutoCompleteTextView) this
.findViewById(R.id.to);
final MobilePhoneAdapter mpa = new MobilePhoneAdapter(this);
final SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(this);
MobilePhoneAdapter.setMobileNumbersOnly(p.getBoolean(
PreferencesActivity.PREFS_MOBILE_ONLY, false));
mtv.setAdapter(mpa);
mtv.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
mtv.setText(to);
if (!TextUtils.isEmpty(to)) {
to = to.trim();
if (to.endsWith(",")) {
to = to.substring(0, to.length() - 1).trim();
}
if (to.indexOf('<') < 0) {
// try to fetch recipient's name from phone book
String n = ContactsWrapper.getInstance().getNameForNumber(
getContentResolver(), to);
if (n != null) {
to = n + " <" + to + ">, ";
}
}
mtv.setText(to);
et.requestFocus();
} else {
mtv.requestFocus();
}
cbmgr = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
int flags = et.getInputType();
if (p.getBoolean(PreferencesActivity.PREFS_EDIT_SHORT_TEXT, true)) {
flags |= InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE;
} else {
flags &= ~InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE;
}
et.setInputType(flags);
}
}
}
示例9: onCreateView
import android.widget.MultiAutoCompleteTextView; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_restore, container, false);
Fonts.setTypeface(view.findViewById(R.id.coins_icon), Fonts.Font.COINOMI_FONT_ICONS);
ImageButton scanQrButton = (ImageButton) view.findViewById(R.id.scan_qr_code);
scanQrButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
handleScan();
}
});
// Setup auto complete the mnemonic words
ArrayAdapter<String> adapter = new ArrayAdapter<>(this.getActivity(),
R.layout.item_simple, MnemonicCode.INSTANCE.getWordList());
mnemonicTextView = (MultiAutoCompleteTextView) view.findViewById(R.id.seed);
mnemonicTextView.setAdapter(adapter);
mnemonicTextView.setTokenizer(new SpaceTokenizer() {
@Override
public void onToken() {
clearError(errorMnemonicΜessage);
}
});
// Restore message
errorMnemonicΜessage = (TextView) view.findViewById(R.id.restore_message);
errorMnemonicΜessage.setVisibility(View.GONE);
bip39Passphrase = (EditText) view.findViewById(R.id.bip39_passphrase);
final View bip39PassphraseTitle = view.findViewById(R.id.bip39_passphrase_title);
bip39Passphrase.setVisibility(View.GONE);
bip39PassphraseTitle.setVisibility(View.GONE);
// For existing seed
final View bip39Info = view.findViewById(R.id.bip39_info);
bip39Info.setVisibility(View.GONE);
final CheckBox useBip39Checkbox = (CheckBox) view.findViewById(R.id.use_bip39);
if (isNewSeed) useBip39Checkbox.setVisibility(View.GONE);
useBip39Checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
isSeedProtected = isChecked;
if (isChecked) {
if (isNewSeed) skipButton.setVisibility(View.GONE);
bip39Info.setVisibility(View.VISIBLE);
bip39PassphraseTitle.setVisibility(View.VISIBLE);
bip39Passphrase.setVisibility(View.VISIBLE);
} else {
if (isNewSeed) skipButton.setVisibility(View.VISIBLE);
bip39Info.setVisibility(View.GONE);
bip39PassphraseTitle.setVisibility(View.GONE);
bip39Passphrase.setVisibility(View.GONE);
bip39Passphrase.setText(null);
}
}
});
// Skip link
skipButton = (Button) view.findViewById(R.id.seed_entry_skip);
if (isNewSeed) {
skipButton.setOnClickListener(getOnSkipListener());
skipButton.setVisibility(View.VISIBLE);
} else {
skipButton.setVisibility(View.GONE);
}
// Next button
view.findViewById(R.id.button_next).setOnClickListener(getOnNextListener());
return view;
}