本文整理汇总了Java中android.widget.AutoCompleteTextView.setAdapter方法的典型用法代码示例。如果您正苦于以下问题:Java AutoCompleteTextView.setAdapter方法的具体用法?Java AutoCompleteTextView.setAdapter怎么用?Java AutoCompleteTextView.setAdapter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.AutoCompleteTextView
的用法示例。
在下文中一共展示了AutoCompleteTextView.setAdapter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import android.widget.AutoCompleteTextView; //导入方法依赖的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.AutoCompleteTextView; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setting = new Setting(this);
setContentView(R.layout.activity_main);
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
setDepartureTime(new Date());
registerSearchButton();
registerOppositeButton();
registerTakeMeHomeButton();
AutoCompleteTextView inputFrom = (AutoCompleteTextView) findViewById(R.id.input_from);
inputFrom.setAdapter(new StationAdapter(this, R.layout.autocomplete_item));
AutoCompleteTextView inputTo= (AutoCompleteTextView) findViewById(R.id.input_to);
inputTo.setAdapter(new StationAdapter(this, R.layout.autocomplete_item));
favorite = new FavoriteModel(this);
ListView listView = (ListView)findViewById(R.id.list_favorites);
FavoriteAdapter favoriteadapter = new FavoriteAdapter(this, favorite);
listView.setAdapter(favoriteadapter);
}
示例3: onCreate
import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setting = new Setting(this);
setContentView(R.layout.activity_setting);
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle(getResources().getString(R.string.settings_title));
AutoCompleteTextView inputTakeMeHome = (AutoCompleteTextView) findViewById(R.id.input_take_me_home);
inputTakeMeHome.setAdapter(new StationAdapter(this, R.layout.autocomplete_item));
inputTakeMeHome.addTextChangedListener(new TextWatcherAdapter() {
@Override
public void afterTextChanged(Editable e) {
setting.saveSettings(R.string.setting_key_take_me_home, e.toString());
}
});
inputTakeMeHome.setText(setting.getSettings(R.string.setting_key_take_me_home, ""), false);
initSettingSelection(R.id.cb_train, R.string.setting_transportation_train);
initSettingSelection(R.id.cb_tram, R.string.setting_transportation_tram);
initSettingSelection(R.id.cb_bus, R.string.setting_transportation_bus);
initSettingSelection(R.id.cb_boat, R.string.setting_transportation_ship);
initSettingSelection(R.id.cb_firstclass, R.string.setting_classes_first);
initSettingSelection(R.id.cb_secondclass, R.string.setting_classes_second);
}
示例4: createLeaderDialog
import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
private void createLeaderDialog() {
autoCompleteTextView =
(AutoCompleteTextView) dialogView.findViewById(R.id.language_autocomplete);
autoCompleteTextView.setAdapter(new ArrayAdapter<>(
getActivity(), android.R.layout.simple_dropdown_item_1line, validLanguages));
validator = new LanguageValidator(getActivity(), autoCompleteTextView, validLanguages);
autoCompleteTextView.setValidator(validator);
autoCompleteTextView.setOnFocusChangeListener(new FocusListener());
autoCompleteTextView.setThreshold(1);
autoCompleteTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
autoCompleteTextView.showDropDown();
}
});
filteredCheckbox = (CheckBox) dialogView.findViewById(R.id.filter_rb);
filteredCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
autoCompleteTextView.setVisibility(isChecked ? View.VISIBLE : View.GONE);
}
});
}
示例5: initializeSearchSuggestions
import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
/**
* method to generate search suggestions for the AutoCompleteTextView from
* previously searched URLs
*/
private void initializeSearchSuggestions(final AutoCompleteTextView getUrl) {
getUrl.setThreshold(1);
getUrl.setDropDownWidth(-1);
getUrl.setDropDownAnchor(R.id.toolbar_layout);
getUrl.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
}
});
getUrl.setSelectAllOnFocus(true);
mSearchAdapter = new SearchAdapter(mActivity, mDarkTheme, isIncognito());
getUrl.setAdapter(mSearchAdapter);
}
示例6: PlaceAutoCompleteHelper
import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
public PlaceAutoCompleteHelper(AutoCompleteTextView ... act, FragmentActivity fa) {
Context ctx = act[0].getContext();
mGoogleApiClient = new GoogleApiClient.Builder(ctx)
.enableAutoManage(fa, 0, this)
.addApi(Places.GEO_DATA_API)
.addApi(LocationServices.API)
.build();
mAdapter = new PlaceAutoCompleteAdapter(ctx, mGoogleApiClient,
null);
for (AutoCompleteTextView ac:act) {
ac.setOnItemClickListener(mAutocompleteClickListener);
ac.setAdapter(mAdapter);
ac.setOnFocusChangeListener(this);
}
placeIcon = act[0].getContext().getResources().getDrawable(R.drawable.ic_map_marker);
}
示例7: onCreate
import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_novo_atendimento);
initToolbar();
instituicao = (AutoCompleteTextView) findViewById(R.id.autoCompleteLocalAtendimento);
profissional = (AutoCompleteTextView) findViewById(R.id.autoCompleteProfissionalSaude);
dataHorario = (Button) findViewById(R.id.button_dados_data_horario_atendimento);
//essas variáveis serão instanciadas chamando os métodos: getNomesLocaisAtendimentos e getNomesProfissionais.
String[] instituicoes = new String[]{"Hospital das Clínicas", "Hospinal Santa Genoveva",
"Hospital HGG", "Hospital do Cancer", "Novo Hospital"};
String[] profissionais = new String[]{"João não sei das quantas", "José Maria",
"Açogueiro do pará", "Médico bom", "Enfermeiro"};
instituicao.setAdapter(adapter(instituicoes));
profissional.setAdapter(adapter(profissionais));
}
示例8: onCreate
import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fake_location);
fake_info = (TextView) findViewById(R.id.fake_info);
fake_info
.setText("开始模拟,在下面的地址填写GPS记录文件与速率!\n" + "可能的位置:"
+ Environment.getExternalStorageDirectory()
+ "/FakeGPS/GPS.db");
// Get a reference to the AutoCompleteTextView in the layout
dbfile = (AutoCompleteTextView) findViewById(R.id.dbfile);
// Get the string array
String[] dbs = getResources().getStringArray(R.array.db_array);
// Create the adapter and set it to the AutoCompleteTextView
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, dbs);
dbfile.setAdapter(adapter);
rate_v = (EditText) findViewById(R.id.edit_text);
}
示例9: createNewTextView
import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
private AutoCompleteTextView createNewTextView(final EditText et) {
final TableRow.LayoutParams lparams = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
final AutoCompleteTextView textView = new AutoCompleteTextView(this.getContext());
lparams.weight = 10;
textView.setHint(R.string.add_ingredient);
textView.setLayoutParams(lparams);
textView.setAdapter(adapter);
textView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
Ingredient ingr = (Ingredient) adapterView.getAdapter().getItem(i);
ViewGroup vg= (ViewGroup) textView.getParent();
setETsForUnits(ingr.getMeasureUnit(),ingr.getMeasureValue(),ingr.getDefaultUnit(),ingr.getDefaultValue(),vg);
}
});
return textView;
}
示例10: onCreateView
import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
/**
* Called to have the fragment instantiate its user interface view.
* This is optional, and non-graphical fragments can return null (which
* is the default implementation). This will be called between
* {@link #onCreate(Bundle)} and {@link #onActivityCreated(Bundle)}.
* <p/>
* <p>If you return a View from here, you will later be called in
* {@link #onDestroyView} when the view is being released.
*
* @param inflater The LayoutInflater object that can be used to inflate
* any views in the fragment,
* @param container If non-null, this is the parent view that the fragment's
* UI should be attached to. The fragment should not add the view itself,
* but this can be used to generate the LayoutParams of the view.
* @param savedInstanceState If non-null, this fragment is being re-constructed
* from a previous saved state as given here.
* @return Return the View for the fragment's UI, or null.
*/
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
setRootView(inflate(inflater, container, R.layout.fragment_login));
emailField = (AutoCompleteTextView) getRootView().findViewById(R.id.login_email);
pwdField = (EditText) getRootView().findViewById(R.id.login_pwd);
pwdLayout = (TextInputLayout) getRootView().findViewById(R.id.login_pwd_layout);
((TextView) getRootView().findViewById(R.id.login_version)).setText(BuildConfig.VERSION_NAME);
setOnClickListeners(R.id.login_btn_ok);
try{
final ArrayList<String> existingAccountNames = new ArrayList<>();
for(Account account : FetLife.getAccountManager().getAccounts())
existingAccountNames.add(account.name);
emailField.setAdapter(new ArrayAdapter<>(
getActivity(), android.R.layout.simple_dropdown_item_1line, existingAccountNames));
} catch (NoAccountsException e) {
// no-op?
}
return getRootView();
}
示例11: showAddTagDialog
import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
void showAddTagDialog() {
AlertDialog.Builder ab = new AlertDialog.Builder(getActivity());
ab.setTitle("Add new tag");
final AutoCompleteTextView tg = new AutoCompleteTextView(getActivity());
tg.setHint("tag");
ArrayAdapter<String> tgadapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_dropdown_item_1line, autocompleteTags);
tg.setAdapter(tgadapter);
ab.setView(tg);
ab.setPositiveButton("Oh yeah", new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface p1, int p2) {
if (entity != null) {
String tag = tg.getText().toString();
entity.addTag(tag);
addParamsByTag(tag);
}
}
});
ab.setNegativeButton("Nooo!", null);
ab.show();
}
示例12: setupAccountHistory
import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
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);
}
}
示例13: loadStationsSuccess
import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
private Response.Listener<JSONArray> loadStationsSuccess() {
return new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
try {
if (response.length() == 0) {
Toast.makeText(FindConnectionActivity.this, TAG + ": " + "No available connections", Toast.LENGTH_LONG).show();
} else {
ArrayList<String> stations = new ArrayList<>();
for (int i = 0; i < response.length(); i++) {
stations.add(response.getJSONObject(i).getString("name"));
}
// Put values into autocomplete text views.
// From autocomplete.
ArrayAdapter<String> fromAdapter = new ArrayAdapter<String>(FindConnectionActivity.this,
android.R.layout.simple_dropdown_item_1line, stations);
AutoCompleteTextView fromTextView = (AutoCompleteTextView) findViewById(R.id.fromAutocomplete);
fromTextView.setAdapter(fromAdapter);
// To autocomplete.
ArrayAdapter<String> toAdapter = new ArrayAdapter<String>(FindConnectionActivity.this,
android.R.layout.simple_dropdown_item_1line, stations);
AutoCompleteTextView toTextView = (AutoCompleteTextView) findViewById(R.id.toAutocomplete);
toTextView.setAdapter(toAdapter);
}
} catch (JSONException e) {
Toast.makeText(FindConnectionActivity.this, TAG + ": " + e.getMessage(), Toast.LENGTH_SHORT).show();
}
}
};
}
示例14: initComponent
import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
private void initComponent() {
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(Places.GEO_DATA_API)
.addConnectionCallbacks(this)
.enableAutoManage(this, this)
.addOnConnectionFailedListener(this)
.build();
btnFind = (Button) findViewById(R.id.findPlace);
placeToGo = (AutoCompleteTextView) findViewById(R.id.inputPlace);
mAdapter = new PlaceAutoCompleteAdapter(this, android.R.layout.simple_list_item_1, mGoogleApiClient, BOUNDS_HCMC, null);
placeToGo.setAdapter(mAdapter);
setAutoSuggestion();
btnFind.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!placeToGo.getText().toString().equals("")) {
moveToPosition();
placeToGo.setText("");
}
else Toast.makeText(MapsActivity2.this, "Please input a place", Toast.LENGTH_SHORT).show();
InputMethodManager inputManager = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);
}
});
}
示例15: init_placeAPI
import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
private void init_placeAPI() {
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(Places.GEO_DATA_API)
.enableAutoManage(this, GOOGLE_API_CLIENT_ID, this)
.addConnectionCallbacks(this)
.build();
addLocation = (AutoCompleteTextView) findViewById(R.id
.addLocation);
addLocation.setThreshold(3);
addLocation.setOnItemClickListener(mAutocompleteClickListener);
mPlaceArrayAdapter = new PlaceAdapter(this, android.R.layout.simple_list_item_1,
BOUNDS_MOUNTAIN_VIEW, null);
addLocation.setAdapter(mPlaceArrayAdapter);
}