本文整理汇总了Java中android.widget.AutoCompleteTextView.setThreshold方法的典型用法代码示例。如果您正苦于以下问题:Java AutoCompleteTextView.setThreshold方法的具体用法?Java AutoCompleteTextView.setThreshold怎么用?Java AutoCompleteTextView.setThreshold使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.AutoCompleteTextView
的用法示例。
在下文中一共展示了AutoCompleteTextView.setThreshold方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
});
}
示例2: 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);
}
示例3: applyStyle
import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
private static void applyStyle(AutoCompleteTextView v, int styleRes){
TypedArray a = v.getContext().obtainStyledAttributes(null, R.styleable.AutoCompleteTextView, 0, styleRes);
int n = a.getIndexCount();
for (int i = 0; i < n; i++) {
int attr = a.getIndex(i);
if(attr == R.styleable.AutoCompleteTextView_android_completionHint)
v.setCompletionHint(a.getString(attr));
else if(attr == R.styleable.AutoCompleteTextView_android_completionThreshold)
v.setThreshold(a.getInteger(attr, 0));
else if(attr == R.styleable.AutoCompleteTextView_android_dropDownAnchor)
v.setDropDownAnchor(a.getResourceId(attr, 0));
else if(attr == R.styleable.AutoCompleteTextView_android_dropDownHeight)
v.setDropDownHeight(a.getLayoutDimension(attr, ViewGroup.LayoutParams.WRAP_CONTENT));
else if(attr == R.styleable.AutoCompleteTextView_android_dropDownWidth)
v.setDropDownWidth(a.getLayoutDimension(attr, ViewGroup.LayoutParams.WRAP_CONTENT));
else if(attr == R.styleable.AutoCompleteTextView_android_dropDownHorizontalOffset)
v.setDropDownHorizontalOffset(a.getDimensionPixelSize(attr, 0));
else if(attr == R.styleable.AutoCompleteTextView_android_dropDownVerticalOffset)
v.setDropDownVerticalOffset(a.getDimensionPixelSize(attr, 0));
else if(attr == R.styleable.AutoCompleteTextView_android_popupBackground)
v.setDropDownBackgroundDrawable(a.getDrawable(attr));
}
a.recycle();
}
示例4: onCreate
import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mGoogleApiClient = new GoogleApiClient.Builder(MainActivity.this)
.addApi(Places.GEO_DATA_API)
.enableAutoManage(this, GOOGLE_API_CLIENT_ID, this)
.addConnectionCallbacks(this)
.build();
mAutocompleteTextView = (AutoCompleteTextView) findViewById(R.id
.autoCompleteTextView);
mAutocompleteTextView.setThreshold(3);
mNameTextView = (TextView) findViewById(R.id.name);
mAddressTextView = (TextView) findViewById(R.id.address);
mIdTextView = (TextView) findViewById(R.id.place_id);
mPhoneTextView = (TextView) findViewById(R.id.phone);
mWebTextView = (TextView) findViewById(R.id.web);
mAttTextView = (TextView) findViewById(R.id.att);
mAutocompleteTextView.setOnItemClickListener(mAutocompleteClickListener);
mPlaceArrayAdapter = new PlaceArrayAdapter(this, android.R.layout.simple_list_item_1,
BOUNDS_MOUNTAIN_VIEW, null);
mAutocompleteTextView.setAdapter(mPlaceArrayAdapter);
}
示例5: 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);
}
}
示例6: 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);
}
示例7: onCreateOptionsMenu
import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_search, menu);
MenuItem searchItem = menu.findItem(R.id.action_search);
SearchView searchView =
(SearchView) MenuItemCompat.getActionView(searchItem);
searchView.setOnQueryTextListener(this);
searchView.setInputType(InputType.TYPE_TEXT_FLAG_CAP_WORDS);
searchView.setQuery(mPresenter.getSearchModels().get(0).getQuery(), false);
if (isInputMode) {
MenuItemCompat.expandActionView(searchItem);
} else {
MenuItemCompat.collapseActionView(searchItem);
}
MenuItemCompat.setOnActionExpandListener(searchItem, this);
AutoCompleteTextView autoCompleteTextView = searchView
.findViewById(android.support.v7.appcompat.R.id.search_src_text);
autoCompleteTextView.setThreshold(0);
autoCompleteTextView.setAdapter(new ArrayAdapter<>(this,
R.layout.layout_item_simple_list, mPresenter.getSearchRecordList()));
autoCompleteTextView.setDropDownBackgroundDrawable(new ColorDrawable(ViewUtils.getWindowBackground(getActivity())));
autoCompleteTextView.setOnItemClickListener((parent, view, position, id) -> {
onQueryTextSubmit(parent.getAdapter().getItem(position).toString());
});
return super.onCreateOptionsMenu(menu);
}
示例8: initializeSearchSuggestions
import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
/**
* method to generate search suggestions for the AutoCompleteTextView from
* previously searched URLs
*/
private void initializeSearchSuggestions(final AutoCompleteTextView getUrl) {
mSuggestionsAdapter = new SuggestionsAdapter(this, mDarkTheme, isIncognito());
getUrl.setThreshold(1);
getUrl.setDropDownWidth(-1);
getUrl.setDropDownAnchor(R.id.toolbar_layout);
getUrl.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int pos, long l) {
String url = null;
CharSequence urlString = ((TextView) view.findViewById(R.id.url)).getText();
if (urlString != null) {
url = urlString.toString();
}
if (url == null || url.startsWith(getString(R.string.suggestion))) {
CharSequence searchString = ((TextView) view.findViewById(R.id.title)).getText();
if (searchString != null) {
url = searchString.toString();
}
}
if (url == null) {
return;
}
getUrl.setText(url);
searchTheWeb(url);
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(getUrl.getWindowToken(), 0);
mPresenter.onAutoCompleteItemPressed();
}
});
getUrl.setSelectAllOnFocus(true);
getUrl.setAdapter(mSuggestionsAdapter);
}
示例9: initializeUi
import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
private void initializeUi() {
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
// Get the Layoutelements
mBtnConnect = (Button) findViewById(R.id.btnConnect);
mBtnConnect.setOnClickListener(oclConnect);
mBtnConnect.requestFocus();
mBtnMiamPlayer = (ImageButton) findViewById(R.id.btnMiamPlayerIcon);
mBtnMiamPlayer.setOnClickListener(oclMiamPlayer);
// Setup the animation for the MiamPlayer icon
mAlphaDown = new AlphaAnimation(1.0f, 0.3f);
mAlphaUp = new AlphaAnimation(0.3f, 1.0f);
mAlphaDown.setDuration(ANIMATION_DURATION);
mAlphaUp.setDuration(ANIMATION_DURATION);
mAlphaDown.setFillAfter(true);
mAlphaUp.setFillAfter(true);
mAlphaUp.setAnimationListener(mAnimationListener);
mAlphaDown.setAnimationListener(mAnimationListener);
mAnimationCancel = false;
// Ip and Autoconnect
mEtIp = (AutoCompleteTextView) findViewById(R.id.etIp);
mEtIp.setRawInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
mEtIp.setThreshold(3);
// Get old ip and auto-connect from shared preferences
mEtIp.setText(mSharedPref.getString(SharedPreferencesKeys.SP_KEY_IP, ""));
mEtIp.setSelection(mEtIp.length());
ArrayAdapter<String> adapter = new ArrayAdapter<>(this,
android.R.layout.select_dialog_item, mKnownIps.toArray(new String[0]));
mEtIp.setAdapter(adapter);
// Get the last auth code
mAuthCode = mSharedPref.getInt(SharedPreferencesKeys.SP_LAST_AUTH_CODE, 0);
}
示例10: applyStyle
import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
/**
* Apply any AutoCompleteTextView style attributes to a view.
* @param v
* @param attrs
* @param defStyleAttr
* @param defStyleRes
*/
private static void applyStyle(AutoCompleteTextView v, AttributeSet attrs, int defStyleAttr, int defStyleRes){
TypedArray a = v.getContext().obtainStyledAttributes(attrs, R.styleable.AutoCompleteTextView, defStyleAttr, defStyleRes);
int n = a.getIndexCount();
for (int i = 0; i < n; i++) {
int attr = a.getIndex(i);
if(attr == R.styleable.AutoCompleteTextView_android_completionHint)
v.setCompletionHint(a.getString(attr));
else if(attr == R.styleable.AutoCompleteTextView_android_completionThreshold)
v.setThreshold(a.getInteger(attr, 0));
else if(attr == R.styleable.AutoCompleteTextView_android_dropDownAnchor)
v.setDropDownAnchor(a.getResourceId(attr, 0));
else if(attr == R.styleable.AutoCompleteTextView_android_dropDownHeight)
v.setDropDownHeight(a.getLayoutDimension(attr, ViewGroup.LayoutParams.WRAP_CONTENT));
else if(attr == R.styleable.AutoCompleteTextView_android_dropDownWidth)
v.setDropDownWidth(a.getLayoutDimension(attr, ViewGroup.LayoutParams.WRAP_CONTENT));
else if(attr == R.styleable.AutoCompleteTextView_android_dropDownHorizontalOffset)
v.setDropDownHorizontalOffset(a.getDimensionPixelSize(attr, 0));
else if(attr == R.styleable.AutoCompleteTextView_android_dropDownVerticalOffset)
v.setDropDownVerticalOffset(a.getDimensionPixelSize(attr, 0));
else if(attr == R.styleable.AutoCompleteTextView_android_popupBackground)
v.setDropDownBackgroundDrawable(a.getDrawable(attr));
}
a.recycle();
}
示例11: showEditBookmarkDialog
import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
private void showEditBookmarkDialog(final Context context, final HistoryItem item) {
final AlertDialog.Builder editBookmarkDialog = new AlertDialog.Builder(context);
editBookmarkDialog.setTitle(R.string.title_edit_bookmark);
final View dialogLayout = View.inflate(context, R.layout.dialog_edit_bookmark, null);
final EditText getTitle = (EditText) dialogLayout.findViewById(R.id.bookmark_title);
getTitle.setText(item.getTitle());
final EditText getUrl = (EditText) dialogLayout.findViewById(R.id.bookmark_url);
getUrl.setText(item.getUrl());
final AutoCompleteTextView getFolder =
(AutoCompleteTextView) dialogLayout.findViewById(R.id.bookmark_folder);
getFolder.setHint(R.string.folder);
getFolder.setText(item.getFolder());
final List<String> folders = bookmarkManager.getFolderTitles();
final ArrayAdapter<String> suggestionsAdapter = new ArrayAdapter<>(context,
android.R.layout.simple_dropdown_item_1line, folders);
getFolder.setThreshold(1);
getFolder.setAdapter(suggestionsAdapter);
editBookmarkDialog.setView(dialogLayout);
editBookmarkDialog.setPositiveButton(context.getString(R.string.action_ok),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
HistoryItem editedItem = new HistoryItem();
editedItem.setTitle(getTitle.getText().toString());
editedItem.setUrl(getUrl.getText().toString());
editedItem.setUrl(getUrl.getText().toString());
editedItem.setFolder(getFolder.getText().toString());
bookmarkManager.editBookmark(item, editedItem);
eventBus.post(new BookmarkEvents.BookmarkChanged(item, editedItem));
}
});
editBookmarkDialog.show();
}
示例12: 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) {
try {
String url;
url = ((TextView) arg1.findViewById(R.id.url)).getText().toString();
if (url.startsWith(BrowserActivity.this.getString(R.string.suggestion))) {
url = ((TextView) arg1.findViewById(R.id.title)).getText().toString();
} else {
getUrl.setText(url);
}
searchTheWeb(url);
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(getUrl.getWindowToken(), 0);
if (mCurrentView != null) {
mCurrentView.requestFocus();
}
} catch (NullPointerException e) {
Log.e("Browser Error: ", "NullPointerException on item click");
}
}
});
getUrl.setSelectAllOnFocus(true);
mSearchAdapter = new SearchAdapter(this, mDarkTheme, isIncognito());
getUrl.setAdapter(mSearchAdapter);
}
示例13: 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) {
try {
String url;
url = ((TextView) arg1.findViewById(R.id.url)).getText().toString();
if (url.startsWith(BrowserActivityInc.this.getString(R.string.suggestion))) {
url = ((TextView) arg1.findViewById(R.id.title)).getText().toString();
} else {
getUrl.setText(url);
}
searchTheWeb(url);
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(getUrl.getWindowToken(), 0);
if (mCurrentView != null) {
mCurrentView.requestFocus();
}
} catch (NullPointerException e) {
Log.e("Browser Error: ", "NullPointerException on item click");
}
}
});
getUrl.setSelectAllOnFocus(true);
mSearchAdapter = new SearchAdapter(this, mDarkTheme, isIncognito());
getUrl.setAdapter(mSearchAdapter);
}
示例14: onCreate
import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle("Add Record");
setContentView(R.layout.activity_add);
subjectEditText = (EditText) findViewById(R.id.editText2);
descEditText = (EditText) findViewById(R.id.editText3);
spinner = (ProgressBar) findViewById(R.id.progressBar2);
new AddActivity.AltcoinRetrieve().execute();
// Double a = (Double)findViewById(R.id.editText3);
ArrayAdapter<String> adapter = new ArrayAdapter<String> (this,android.R.layout.select_dialog_item,list);
//Getting the instance of AutoCompleteTextView
AutoCompleteTextView actv= (AutoCompleteTextView)findViewById(R.id.coinlist);
actv.setThreshold(1);//will start working from first character
actv.setAdapter(adapter);//setting the adapter data into the AutoCompleteTextView
actv.setTextColor(Color.RED);
button = (Button) findViewById(R.id.button);
// final String name = subjectEditText.getText().toString();
//final String desc = descEditText.getText().toString();
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
try {
SQLiteDatabase db;
db = openOrCreateDatabase("PORTFOLIO", Context.MODE_PRIVATE, null);
db.execSQL("CREATE TABLE IF NOT EXISTS coinpryc(id INTEGER PRIMARY KEY AUTOINCREMENT,name VARCHAR(20),amount DOUBLE,price DOUBLE);");
Double a = Double.parseDouble(subjectEditText.getText().toString());
//Double a = subjectEditText;
System.out.println("a " + a);
Double b = Double.parseDouble(descEditText.getText().toString());
System.out.println("b " + b);
// Cursor c=db.rawQuery("SELECT * FROM bitdata", null);
db.execSQL("INSERT INTO coinpryc (name,amount,price) VALUES('" + a + "','" + b + "');");
Intent activity = new Intent(AddActivity.this, FifthActivity.class);
AddActivity.this.startActivity(activity);
}
catch (SQLiteException e)
{
Log.e("SQL Error",e.getMessage(),e);
}
}
});
}
示例15: onCreateView
import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_technicolor, container, false);
loading = view.findViewById(R.id.loading_spinner);
mainView = view.findViewById(R.id.main_view);
final CheckBox freq24 = (CheckBox) view.findViewById(R.id.radio_24);
final CheckBox freq5 = (CheckBox) view.findViewById(R.id.radio_5);
final AutoCompleteTextView edit = (AutoCompleteTextView) view
.findViewById(R.id.manual_autotext);
final String[] routers = getResources().getStringArray(
R.array.supported_routers);
ArrayAdapter<String> adapter = new ArrayAdapter<>(getActivity(),
android.R.layout.simple_dropdown_item_1line, routers);
edit.setAdapter(adapter);
edit.setThreshold(1);
edit.requestFocus();
final InputFilter filterSSID = new InputFilter() {
public CharSequence filter(CharSequence source, int start, int end,
Spanned dest, int dstart, int dend) {
for (int i = start; i < end; i++) {
if (!Character.isLetterOrDigit(source.charAt(i))
&& source.charAt(i) != '-'
&& source.charAt(i) != '_'
&& source.charAt(i) != ' ') {
return "";
}
}
return null;
}
};
final InputFilter lengthFilter = new InputFilter.LengthFilter(8); //Filter to 10 characters
edit.setFilters(new InputFilter[]{filterSSID, lengthFilter});
edit.setImeOptions(EditorInfo.IME_ACTION_DONE);
Button calc = (Button) view.findViewById(R.id.bt_calc);
calc.setOnClickListener(new View.OnClickListener() {
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void onClick(View v) {
String ssid = "UPC" + edit.getText().toString().trim();
if (!freq24.isChecked() && !freq5.isChecked()) {
freq24.setChecked(true);
freq5.setChecked(true);
}
int mode = (freq24.isChecked() ? 1 : 0) | (freq5.isChecked() ? 2 : 0);
KeygenMatcherTask matcher = new KeygenMatcherTask(ssid, mode);
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
matcher.execute();
} else {
matcher.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}
});
return view;
}