本文整理汇总了Java中android.widget.AutoCompleteTextView.addTextChangedListener方法的典型用法代码示例。如果您正苦于以下问题:Java AutoCompleteTextView.addTextChangedListener方法的具体用法?Java AutoCompleteTextView.addTextChangedListener怎么用?Java AutoCompleteTextView.addTextChangedListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.AutoCompleteTextView
的用法示例。
在下文中一共展示了AutoCompleteTextView.addTextChangedListener方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: onCreate
import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_realtime_bus_query);
context=getBaseContext();
lineNumber_actv = (AutoCompleteTextView) findViewById(R.id.line_number_actv);
lineNumber_actv.addTextChangedListener(this);
db=LocalSql.getInstance(getApplicationContext());
setNewDict("");
lineNumber_actv.setAdapter(actAdapter);
lineQueryBTN = (Button) findViewById(R.id.line_query_btn);
fromStationTV = (TextView) findViewById(R.id.from_station_tv);
toStationTV = (TextView) findViewById(R.id.to_station_tv);
directionTV = (TextView) findViewById(R.id.dictionary_tv);
refreshFAT = (FloatingActionButton) findViewById(R.id.refresh_fat);
refreshFAT.setOnClickListener(this);
runningBusAndStationRV = (RecyclerView) findViewById(R.id.running_bus_and_station_rv);
GridLayoutManager layoutManager=new GridLayoutManager(this,1);
runningBusAndStationRV.setLayoutManager(layoutManager);
lineQueryBTN.setOnClickListener(this);
}
示例3: buildForm
import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
private void buildForm() {
EditText formMessage = findViewById(R.id.form_input_message);
AutoCompleteTextView formContact = findViewById(R.id.form_input_contact);
TextWatcher watcherEmptiness = new EmptinessTextWatcher(this, formContact, formMessage);
formContact.addTextChangedListener(watcherEmptiness);
formMessage.addTextChangedListener(watcherEmptiness);
new BuilderMessage().setView(formMessage).setSms(sms).build();
new BuilderContact().setView(formContact).setSms(sms).setActivity(this).build();
new BuilderSimCard().setActivity(this).setView(findViewById(R.id.form_sim_card)).setSms(sms).build();
new BuilderRecurringMode()
.setRecurringDayView((Spinner) findViewById(R.id.form_recurring_day))
.setRecurringMonthView((Spinner) findViewById(R.id.form_recurring_month))
.setDateView((DatePicker) findViewById(R.id.form_date))
.setActivity(this)
.setView(findViewById(R.id.form_recurring_mode))
.setSms(sms)
.build()
;
new BuilderTime().setActivity(this).setView(findViewById(R.id.form_time)).setSms(sms).build();
new BuilderDate().setActivity(this).setView(findViewById(R.id.form_date)).setSms(sms).build();
new BuilderCancel().setView(findViewById(R.id.button_cancel)).setSms(sms).build();
}
示例4: setup
import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
private void setup() {
mSearchText = (AutoCompleteTextView) findViewById(R.id.etInput);
mSearchText.addTextChangedListener(this);
mSearchText.setHint(getString(R.string.search_map));
findViewById(R.id.search_back).setOnClickListener(view -> {
finish();
});
mSearchText.setOnEditorActionListener((textView, i, keyEvent) -> {
if (i == EditorInfo.IME_ACTION_SEARCH) {
doSearch();
}
return false;
});
}
示例5: EditSipUri
import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
public EditSipUri(Context context, AttributeSet attrs) {
super(context, attrs);
setGravity(Gravity.CENTER_HORIZONTAL);
setOrientation(VERTICAL);
LayoutInflater inflater = LayoutInflater.from(context);
inflater.inflate(R.layout.edit_sip_uri, this, true);
dialUser = (AutoCompleteTextView) findViewById(R.id.dialtxt_user);
accountChooserButtonText = (AccountChooserButton) findViewById(R.id.accountChooserButtonText);
domainTextHelper = (TextView) findViewById(R.id.dialtxt_domain_helper);
completeList = (ListView) findViewById(R.id.autoCompleteList);
// Map events
accountChooserButtonText.setOnAccountChangeListener(new OnAccountChangeListener() {
@Override
public void onChooseAccount(SipProfile account) {
updateDialTextHelper();
long accId = SipProfile.INVALID_ID;
if (account != null) {
accId = account.id;
}
if(contactsAdapter != null) {
contactsAdapter.setSelectedAccount(accId);
}
}
});
dialUser.addTextChangedListener(this);
}
示例6: onCreate
import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_poi_search);
getSupportActionBar().hide();
EventBus.getDefault().register(this);
AutoCompleteTextView mKeywordText = (AutoCompleteTextView)findViewById(R.id.input_edittext);
mKeywordText.addTextChangedListener(this);
findViewById(R.id.rl_tv_map_pick).setOnClickListener(this);
mRecyclerView = (RecyclerView) findViewById(R.id.ll_rv_inputlist);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mAdapter = getAdapter();
mRecyclerView.setAdapter(mAdapter);
}
示例7: generate
import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
/**
* @param editField The component to "transform" into one that shows a city drop down list
* based on the current input. Make sure to pass an initialized object,
* else a java.lang.NullPointerException will be thrown.
* @param listLimit Determines how many items shall be shown in the drop down list at most.
*/
public void generate(AutoCompleteTextView editField, int listLimit, final int enterActionId, final MyConsumer<City> cityConsumer, final Runnable selectAction) {
cityAdapter = new ArrayAdapter<>(context, android.R.layout.simple_list_item_1, new ArrayList<City>());
this.editField = editField;
this.cityConsumer = cityConsumer;
this.listLimit = listLimit;
editField.setAdapter(cityAdapter);
editField.addTextChangedListener(new TextChangeListener());
editField.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
selectedCity = (City) parent.getItemAtPosition(position);
cityConsumer.accept(selectedCity);
}
});
editField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == enterActionId) {
Boolean checkCity = checkCity();
if (checkCity) {
selectAction.run();
}
return true;
}
return false;
}
});
}
示例8: addLayoutTextChangedListener
import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
public void addLayoutTextChangedListener(TextWatcher textWatcher){
listTextWatcher.add(textWatcher);
if (this.getChildCount() > 0){
AutoCompleteTextView autoCompleteTextView = (AutoCompleteTextView) ((ViewGroup)this.getChildAt(this.getChildCount()-1)).getChildAt(labelPosition);
autoCompleteTextView.addTextChangedListener(textWatcher);
}
}
示例9: setUpMap
import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
/**
* 设置页面监听
*/
private void setUpMap() {
Button searButton = (Button) findViewById(R.id.searchButton);
searButton.setOnClickListener(this);
Button nextButton = (Button) findViewById(R.id.nextButton);
nextButton.setOnClickListener(this);
searchText = (AutoCompleteTextView) findViewById(R.id.keyWord);
searchText.addTextChangedListener(this);// 添加文本输入框监听事件
editCity = (EditText) findViewById(R.id.city);
aMap.setOnMarkerClickListener(this);// 添加点击marker监听事件
aMap.setInfoWindowAdapter(this);// 添加显示infowindow监听事件
}
示例10: onCreate
import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_movie_edit);
_movieDto = (MovieDto) getIntent().getSerializableExtra(MovieService.MovieIntent);
_receiverController = new ReceiverController(this);
final AutoCompleteTextView movieTitleTypeTextView = findViewById(R.id.movie_edit_title_textview);
final AutoCompleteTextView movieGenreTypeTextView = findViewById(R.id.movie_edit_genre_textview);
final AutoCompleteTextView movieDescriptionTypeTextView = findViewById(R.id.movie_edit_description_textview);
final RatingBar movieRatingBar = findViewById(R.id.movieRating_Bar);
_saveButton = findViewById(R.id.save_movie_edit_button);
movieTitleTypeTextView.setAdapter(new ArrayAdapter<>(MovieEditActivity.this, android.R.layout.simple_dropdown_item_1line, MovieService.getInstance().GetTitleList()));
movieTitleTypeTextView.addTextChangedListener(_textWatcher);
movieGenreTypeTextView.setAdapter(new ArrayAdapter<>(MovieEditActivity.this, android.R.layout.simple_dropdown_item_1line, MovieService.getInstance().GetGenreList()));
movieGenreTypeTextView.addTextChangedListener(_textWatcher);
movieDescriptionTypeTextView.setAdapter(new ArrayAdapter<>(MovieEditActivity.this, android.R.layout.simple_dropdown_item_1line, MovieService.getInstance().GetDescriptionList()));
movieDescriptionTypeTextView.addTextChangedListener(_textWatcher);
if (_movieDto != null) {
movieTitleTypeTextView.setText(_movieDto.GetTitle());
movieGenreTypeTextView.setText(_movieDto.GetGenre());
movieDescriptionTypeTextView.setText(_movieDto.GetDescription());
movieRatingBar.setRating(_movieDto.GetRating());
} else {
displayErrorSnackBar("Cannot work with data! Is corrupt! Please try again!");
}
_saveButton.setEnabled(false);
_saveButton.setOnClickListener(view -> {
movieTitleTypeTextView.setError(null);
movieGenreTypeTextView.setError(null);
movieDescriptionTypeTextView.setError(null);
boolean cancel = false;
View focusView = null;
if (!_propertyChanged) {
movieTitleTypeTextView.setError(createErrorText(getString(R.string.error_nothing_changed)));
focusView = movieTitleTypeTextView;
cancel = true;
}
String title = movieTitleTypeTextView.getText().toString();
if (TextUtils.isEmpty(title)) {
movieTitleTypeTextView.setError(createErrorText(getString(R.string.error_field_required)));
focusView = movieTitleTypeTextView;
cancel = true;
}
String genre = movieGenreTypeTextView.getText().toString();
if (TextUtils.isEmpty(genre)) {
movieGenreTypeTextView.setError(createErrorText(getString(R.string.error_field_required)));
focusView = movieGenreTypeTextView;
cancel = true;
}
String description = movieDescriptionTypeTextView.getText().toString();
if (TextUtils.isEmpty(description)) {
movieDescriptionTypeTextView.setError(createErrorText(getString(R.string.error_nothing_changed)));
focusView = movieDescriptionTypeTextView;
cancel = true;
}
if (cancel) {
focusView.requestFocus();
} else {
MovieService.getInstance().UpdateMovie(new Movie(_movieDto.GetId(), title, genre, description, (int) movieRatingBar.getRating(), _movieDto.GetWatched()));
_saveButton.setEnabled(false);
}
});
}
示例11: onCreate
import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_menu_edit);
_menuDto = (MenuDto) getIntent().getSerializableExtra(MenuService.MenuIntent);
_receiverController = new ReceiverController(this);
final TextView dateTextView = findViewById(R.id.menuDateTextView);
final AutoCompleteTextView menuTitleTypeTextView = findViewById(R.id.menu_edit_title_textview);
final AutoCompleteTextView menuDescriptionTypeTextView = findViewById(R.id.menu_edit_description_textview);
_saveButton = findViewById(R.id.save_menu_edit_button);
menuTitleTypeTextView.setAdapter(new ArrayAdapter<>(MenuEditActivity.this, android.R.layout.simple_dropdown_item_1line, MenuService.getInstance().GetMenuTitleList()));
menuTitleTypeTextView.addTextChangedListener(_textWatcher);
menuDescriptionTypeTextView.setAdapter(new ArrayAdapter<>(MenuEditActivity.this, android.R.layout.simple_dropdown_item_1line, MenuService.getInstance().GetMenuDescriptionList()));
menuDescriptionTypeTextView.addTextChangedListener(_textWatcher);
if (_menuDto != null) {
dateTextView.setText(_menuDto.GetDateString());
menuTitleTypeTextView.setText(_menuDto.GetTitle());
menuDescriptionTypeTextView.setText(_menuDto.GetDescription());
} else {
displayErrorSnackBar("Cannot work with data! Is corrupt! Please try again!");
}
FloatingActionButton randomMenuButton = findViewById(R.id.menuRandomEntry_Button);
randomMenuButton.setOnClickListener(view -> {
SerializableList<ListedMenu> listedMenuList = ListedMenuService.getInstance().GetDataList();
Random randomMenuId = new Random();
int menuId = randomMenuId.nextInt(listedMenuList.getSize());
ListedMenu menu = listedMenuList.getValue(menuId);
menuTitleTypeTextView.setText(menu.GetTitle());
menuDescriptionTypeTextView.setText(menu.GetDescription());
});
_saveButton.setEnabled(false);
_saveButton.setOnClickListener(view -> {
menuTitleTypeTextView.setError(null);
menuDescriptionTypeTextView.setError(null);
boolean cancel = false;
View focusView = null;
if (!_propertyChanged) {
menuTitleTypeTextView.setError(createErrorText(getString(R.string.error_nothing_changed)));
focusView = menuTitleTypeTextView;
cancel = true;
}
String title = menuTitleTypeTextView.getText().toString();
if (TextUtils.isEmpty(title)) {
menuTitleTypeTextView.setError(createErrorText(getString(R.string.error_field_required)));
focusView = menuTitleTypeTextView;
cancel = true;
}
String description = menuDescriptionTypeTextView.getText().toString();
if (TextUtils.isEmpty(description)) {
menuDescriptionTypeTextView.setError(createErrorText(getString(R.string.error_field_required)));
focusView = menuDescriptionTypeTextView;
cancel = true;
}
if (cancel) {
focusView.requestFocus();
} else {
MenuService.getInstance().UpdateMenu(new LucaMenu(_menuDto.GetId(), title, description, _menuDto.GetWeekday(), _menuDto.GetDate(), false, ILucaClass.LucaServerDbAction.Update));
_saveButton.setEnabled(false);
}
});
}
示例12: onCreate
import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_item_shopping_list);
try {
shoppingList = ShoppingListDAO.select(this, getIntent().getExtras().getInt((getString(R.string.id_shopping_list))));
} catch (VansException e) {
Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
e.printStackTrace();
}
this.setTitle(shoppingList.getName());
lvItensShoppingList = (ListView) findViewById(R.id.lvItemShoppingList);
lvItensShoppingList.setOnItemClickListener(this);
lvItensShoppingList.setOnItemLongClickListener(this);
headerView = (View) getLayoutInflater().inflate(R.layout.header_list_view_item_shopping_list, null);
lvItensShoppingList.addHeaderView(headerView, null, false);
adapter = new ItemShoppingListCursorAdapter(this, shoppingList.getId());
lvItensShoppingList.setAdapter(adapter);
edUnitValue = (EditText) findViewById(R.id.edUnitValue);
edUnitValue.setVisibility(UserPreferences.getShowUnitValue(this) ? View.VISIBLE : View.GONE);
edUnitValue.setOnKeyListener(this);
edUnitValue.addTextChangedListener(new CustomEditTextWatcher(edUnitValue, 5));
edUnitValue.setOnFocusChangeListener(this);
edQuantity = (EditText) findViewById(R.id.edQuantity);
edQuantity.addTextChangedListener(new CustomEditTextWatcher(edQuantity, 4));
edQuantity.setVisibility(UserPreferences.getShowQuantity(this) ? View.VISIBLE : View.GONE);
edQuantity.setOnFocusChangeListener(this);
edDescription = (AutoCompleteTextView) findViewById(R.id.edDescription);
edDescription.setOnItemClickListener(this);
edDescription.addTextChangedListener(new CustomEditTextWatcher(edDescription, -1));
if ((!UserPreferences.getShowQuantity(this)) && (!UserPreferences.getShowUnitValue(this))) {
edDescription.setImeOptions(EditorInfo.IME_ACTION_GO);
edDescription.setOnKeyListener(this);
} else if (!UserPreferences.getShowUnitValue(this)) {
edQuantity.setImeOptions(EditorInfo.IME_ACTION_GO);
edQuantity.setOnKeyListener(this);
}
}