本文整理汇总了Java中android.widget.AutoCompleteTextView.setDropDownAnchor方法的典型用法代码示例。如果您正苦于以下问题:Java AutoCompleteTextView.setDropDownAnchor方法的具体用法?Java AutoCompleteTextView.setDropDownAnchor怎么用?Java AutoCompleteTextView.setDropDownAnchor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.AutoCompleteTextView
的用法示例。
在下文中一共展示了AutoCompleteTextView.setDropDownAnchor方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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();
}
示例3: 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);
}
示例4: 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();
}
示例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) {
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);
}
示例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) {
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);
}