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


Java AutoCompleteTextView.setThreshold方法代碼示例

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

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

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

示例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);
}
 
開發者ID:Truiton,項目名稱:PlaceAPIAutocomplete,代碼行數:24,代碼來源:MainActivity.java

示例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);
    }
}
 
開發者ID:mithrilcoin-io,項目名稱:EosCommander,代碼行數:11,代碼來源:UiUtils.java

示例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);
}
 
開發者ID:alewin,項目名稱:moneytracking,代碼行數:16,代碼來源:NewItemActivity.java

示例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);
}
 
開發者ID:ThirtyDegreesRay,項目名稱:OpenHub,代碼行數:29,代碼來源:SearchActivity.java

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

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

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

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

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

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

示例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);
            }
        }
    });



}
 
開發者ID:someaditya,項目名稱:CoinPryc,代碼行數:56,代碼來源:AddActivity.java

示例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;
}
 
開發者ID:yolosec,項目名稱:upcKeygen,代碼行數:64,代碼來源:TechnicolorFragment.java


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