當前位置: 首頁>>代碼示例>>Java>>正文


Java AutoCompleteTextView.setDropDownAnchor方法代碼示例

本文整理匯總了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);
}
 
開發者ID:NewCasino,項目名稱:browser,代碼行數:23,代碼來源:BrowserActivity.java

示例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();
}
 
開發者ID:rey5137,項目名稱:chameleon,代碼行數:27,代碼來源:ViewStyler.java

示例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);
}
 
開發者ID:XndroidDev,項目名稱:Xndroid,代碼行數:42,代碼來源:BrowserActivity.java

示例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();
}
 
開發者ID:XhinLiang,項目名稱:MDPreference,代碼行數:34,代碼來源:ViewUtil.java

示例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);
}
 
開發者ID:javadtaghia,項目名稱:DeeBrowser,代碼行數:39,代碼來源:BrowserActivity.java

示例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);
}
 
開發者ID:javadtaghia,項目名稱:DeeBrowser,代碼行數:39,代碼來源:BrowserActivityInc.java


注:本文中的android.widget.AutoCompleteTextView.setDropDownAnchor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。