本文整理汇总了Java中android.widget.AutoCompleteTextView类的典型用法代码示例。如果您正苦于以下问题:Java AutoCompleteTextView类的具体用法?Java AutoCompleteTextView怎么用?Java AutoCompleteTextView使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AutoCompleteTextView类属于android.widget包,在下文中一共展示了AutoCompleteTextView类的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: dispatchTouchEvent
import android.widget.AutoCompleteTextView; //导入依赖的package包/类
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
View v = getCurrentFocus();
boolean ret = super.dispatchTouchEvent(event);
if (v instanceof AutoCompleteTextView) {
View currentFocus = getCurrentFocus();
int screenCoords[] = new int[2];
currentFocus.getLocationOnScreen(screenCoords);
float x = event.getRawX() + currentFocus.getLeft() - screenCoords[0];
float y = event.getRawY() + currentFocus.getTop() - screenCoords[1];
if (event.getAction() == MotionEvent.ACTION_UP
&& (x < currentFocus.getLeft() ||
x >= currentFocus.getRight() ||
y < currentFocus.getTop() ||
y > currentFocus.getBottom())) {
InputMethodManager imm =
(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(getWindow().getCurrentFocus().getWindowToken(), 0);
v.clearFocus();
}
}
return ret;
}
示例5: 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);
}
});
}
示例6: 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);
}
示例7: onSuggestResult
import android.widget.AutoCompleteTextView; //导入依赖的package包/类
@Override
public void onSuggestResult(final Place place, final AutoCompleteTextView act) {
final LatLng placelatlng=place.getLatLng();
if (!isNavigationReady() && (addr_from.getText().length() < 1 || addr_to.getText().length() < 1))
gmaps.animateCamera(CameraUpdateFactory.newLatLng(place.getLatLng()), 1000, new GoogleMap.CancelableCallback(){
@Override
public void onFinish() {
setAddrValue(act == addr_from ?addr_from: addr_to, placelatlng);
}
@Override
public void onCancel() {
setAddrValue(act == addr_from ?addr_from: addr_to, placelatlng);
}
});
else setAddrValue(act == addr_from ?addr_from: addr_to, placelatlng);
}
示例8: 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);
}
示例9: enterAnimationsForToolbarSearch
import android.widget.AutoCompleteTextView; //导入依赖的package包/类
/**
* Starts the enter animations for various UI components of the toolbar subreddit search
*
* @param ANIMATION_DURATION duration of the animation in ms
* @param SUGGESTIONS_BACKGROUND background of subreddit suggestions list
* @param GO_TO_SUB_FIELD search field in toolbar
* @param CLOSE_BUTTON button that clears the search and closes the search UI
*/
public void enterAnimationsForToolbarSearch(final long ANIMATION_DURATION,
final CardView SUGGESTIONS_BACKGROUND, final AutoCompleteTextView GO_TO_SUB_FIELD,
final ImageView CLOSE_BUTTON) {
SUGGESTIONS_BACKGROUND.animate()
.translationY(headerHeight)
.setInterpolator(new AccelerateDecelerateInterpolator())
.setDuration(ANIMATION_DURATION + ANIMATE_DURATION_OFFSET)
.start();
GO_TO_SUB_FIELD.animate()
.alpha(1f)
.setInterpolator(new AccelerateDecelerateInterpolator())
.setDuration(ANIMATION_DURATION)
.start();
CLOSE_BUTTON.animate()
.alpha(1f)
.setInterpolator(new AccelerateDecelerateInterpolator())
.setDuration(ANIMATION_DURATION)
.start();
}
示例10: AutoCompleteTextViewReflector
import android.widget.AutoCompleteTextView; //导入依赖的package包/类
AutoCompleteTextViewReflector() {
try {
this.doBeforeTextChanged = AutoCompleteTextView.class.getDeclaredMethod("doBeforeTextChanged", new Class[0]);
this.doBeforeTextChanged.setAccessible(true);
} catch (NoSuchMethodException e) {
}
try {
this.doAfterTextChanged = AutoCompleteTextView.class.getDeclaredMethod("doAfterTextChanged", new Class[0]);
this.doAfterTextChanged.setAccessible(true);
} catch (NoSuchMethodException e2) {
}
try {
this.ensureImeVisible = AutoCompleteTextView.class.getMethod("ensureImeVisible", new Class[]{Boolean.TYPE});
this.ensureImeVisible.setAccessible(true);
} catch (NoSuchMethodException e3) {
}
try {
this.showSoftInputUnchecked = InputMethodManager.class.getMethod("showSoftInputUnchecked", new Class[]{Integer.TYPE, ResultReceiver.class});
this.showSoftInputUnchecked.setAccessible(true);
} catch (NoSuchMethodException e4) {
}
}
示例11: onAutofillEvent
import android.widget.AutoCompleteTextView; //导入依赖的package包/类
@Override
public void onAutofillEvent(@NonNull View view, int event) {
if (view instanceof AutoCompleteTextView) {
switch (event) {
case AutofillManager.AutofillCallback.EVENT_INPUT_UNAVAILABLE:
// no break on purpose
case AutofillManager.AutofillCallback.EVENT_INPUT_HIDDEN:
if (!mAutofillReceived) {
((AutoCompleteTextView) view).showDropDown();
}
break;
case AutofillManager.AutofillCallback.EVENT_INPUT_SHOWN:
mAutofillReceived = true;
((AutoCompleteTextView) view).setAdapter(null);
break;
default:
Log.d(TAG, "Unexpected callback: " + event);
}
}
}
开发者ID:googlesamples,项目名称:android-AutofillFramework,代码行数:21,代码来源:StandardAutoCompleteSignInActivity.java
示例12: onCreateView
import android.widget.AutoCompleteTextView; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_template_add_edit, container, false);
ButterKnife.bind(this, rootView);
pagerAdapter = new SpansPagerAdapter();
viewPager.setAdapter(pagerAdapter);
editPattern.setCustomSelectionActionModeCallback(callback);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
editPattern.setCustomInsertionActionModeCallback(insertCallback);
}
ButterKnife.apply(autoCompleteTextViews, new ButterKnife.Setter<AutoCompleteTextView, Object>() {
@Override
public void set(@NonNull AutoCompleteTextView view, Object value, int index) {
}
},null );
return rootView;
}
示例13: 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);
}
示例14: onCreate
import android.widget.AutoCompleteTextView; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
mEmailView = (AutoCompleteTextView) findViewById(R.id.email);
mPasswordView = (EditText) findViewById(R.id.password);
mEmailSignInButton = (Button) findViewById(R.id.email_sign_in_button);
mClickButton = (Button) findViewById(R.id.click_counter_button);
mClickResultText = (TextView) findViewById(R.id.latest_click_result_textview);
mMotivationText = (TextView) findViewById(R.id.motivation_textview);
mDisposables = new CompositeDisposable();
setupRxLoginForm();
setupRxClickCounter();
}
示例15: initView
import android.widget.AutoCompleteTextView; //导入依赖的package包/类
@Override
public void initView(View view) {
atxtPhoneNumber = (AutoCompleteTextView) view.findViewById(R.id.atxtPhoneNumber);
btnSecurityCode = (Button) view.findViewById(R.id.btnSecurityCode);
btnLoginByPhone = (Button) view.findViewById(R.id.btnLoginByPhone);
editSecurityCode = (EditText) view.findViewById(R.id.editSecurityCode);
imgClearPhoneNumber = (ImageView) view.findViewById(R.id.imgClearPhoneNumber);
imgClearSecurityCode = (ImageView) view.findViewById(R.id.imgClearSecurityCode);
//设定计时器
runnable = new Runnable() {
@Override
public void run() {
if (timeCount > 0) {
btnSecurityCode.setText(" " + timeCount-- + "s重新获取 ");
handler.postDelayed(this, 1000);
} else {
btnSecurityCode.setText(" 重新获取 ");
btnSecurityCode.setEnabled(true);
timeCount = 60;
//停止计时器
handler.removeCallbacks(runnable);
}
}
};
}