Java 类android.widget.AutoCompleteTextView 实例源码

项目:snu-artoon    文件:MainActivity.java   
@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);
}
项目:Fahrplan    文件:MainActivity.java   
@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);
}
项目:Fahrplan    文件:SettingActivity.java   
@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);
}
项目:quiz_helper    文件:PopupActivity.java   
@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;
}
项目:CodeWatch    文件:LeaderboardFragment.java   
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);
        }
    });
}
项目:browser    文件:BrowserActivity.java   
/**
 * 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);
}
项目:go-jay    文件:MainActivity.java   
@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);
}
项目:go-jay    文件:PlaceAutoCompleteHelper.java   
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);
}
项目:go-jay    文件:PlaceAutoCompleteHelper.java   
public PlaceAutoCompleteHelper(AutoCompleteTextView... act) {
    Context ctx = act[0].getContext();
    mGoogleApiClient = new GoogleApiClient.Builder(ctx)
        .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);
    }

    //((Activity)ctx).getApplication().registerActivityLifecycleCallbacks(this);
}
项目:Slide-RSS    文件:MainActivity.java   
/**
 * 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();
}
项目:boohee_v5.6    文件:SearchView.java   
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) {
    }
}
项目:android-AutofillFramework    文件:StandardAutoCompleteSignInActivity.java   
@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);
        }
    }
}
项目:Samantha    文件:EditTemplatePatternFragment.java   
@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;
}
项目:ZhuHaiBusApplication    文件:RealTimeBusQueryActivity.java   
@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);
}
项目:youkes_browser    文件:BrowserActivity.java   
/**
 * 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);
}
项目:RxJavaExamples    文件:RxExamplesActivity.java   
@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();
}
项目:iReading    文件:LoginByPhoneFragment.java   
@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);
            }
        }
    };
}
项目:ankihelper    文件:PopupActivity.java   
@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;
}
项目:SmsScheduler    文件:AddSmsActivity.java   
private void buildForm() {
    EditText formMessage = findViewById(R.id.form_input_message);
    AutoCompleteTextView formContact = findViewById(R.id.form_input_contact);
    TextWatcher watcherEmptiness = new EmptinessTextWatcher(this, formContact, formMessage);
    formContact.addTextChangedListener(watcherEmptiness);
    formMessage.addTextChangedListener(watcherEmptiness);

    new BuilderMessage().setView(formMessage).setSms(sms).build();
    new BuilderContact().setView(formContact).setSms(sms).setActivity(this).build();

    new BuilderSimCard().setActivity(this).setView(findViewById(R.id.form_sim_card)).setSms(sms).build();
    new BuilderRecurringMode()
        .setRecurringDayView((Spinner) findViewById(R.id.form_recurring_day))
        .setRecurringMonthView((Spinner) findViewById(R.id.form_recurring_month))
        .setDateView((DatePicker) findViewById(R.id.form_date))
        .setActivity(this)
        .setView(findViewById(R.id.form_recurring_mode))
        .setSms(sms)
        .build()
    ;

    new BuilderTime().setActivity(this).setView(findViewById(R.id.form_time)).setSms(sms).build();
    new BuilderDate().setActivity(this).setView(findViewById(R.id.form_date)).setSms(sms).build();

    new BuilderCancel().setView(findViewById(R.id.button_cancel)).setSms(sms).build();
}
项目:bounswe2016group2    文件:LoginActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);
    SessionManager.clearCredet(this);
    if (SessionManager.isUserLoggedIn(this, "token") ) {
        // User is already logged in
        Intent intent = new Intent(LoginActivity.this, UserHomeActivity.class);
        startActivity(intent);
        LoginActivity.this.finish();
    }
    // Set up the login form.
    mEmailView = (AutoCompleteTextView) findViewById(R.id.email);
    populateAutoComplete();
    switchToRegBut = (Button) findViewById(R.id.button_to_register);
    switchToRegBut.setPaintFlags(switchToRegBut.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
    mPasswordView = (EditText) findViewById(R.id.password);


    Button mEmailSignInButton = (Button) findViewById(R.id.email_sign_in_button);

    mLoginFormView = findViewById(R.id.login_form);
    mProgressView = findViewById(R.id.login_progress);
}
项目:nmud    文件:EntityFragment.java   
void showAddTagDialog() {
    AlertDialog.Builder ab = new AlertDialog.Builder(getActivity());
    ab.setTitle("Add new tag");

    final AutoCompleteTextView tg = new AutoCompleteTextView(getActivity());
    tg.setHint("tag");
    ArrayAdapter<String> tgadapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_dropdown_item_1line, autocompleteTags);
    tg.setAdapter(tgadapter);

    ab.setView(tg);
    ab.setPositiveButton("Oh yeah", new DialogInterface.OnClickListener(){

            @Override
            public void onClick(DialogInterface p1, int p2) {
                if (entity != null) {
                    String tag = tg.getText().toString();
                    entity.addTag(tag);
                    addParamsByTag(tag);
                }
            }
        });
    ab.setNegativeButton("Nooo!", null);
    ab.show();
}
项目:bounswe2016group2    文件:FoodAddFragment.java   
private AutoCompleteTextView createNewTextView(final EditText et) {
    final TableRow.LayoutParams lparams = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
    final AutoCompleteTextView textView = new AutoCompleteTextView(this.getContext());
    lparams.weight = 10;
    textView.setHint(R.string.add_ingredient);
    textView.setLayoutParams(lparams);
    textView.setAdapter(adapter);
    textView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            Ingredient ingr = (Ingredient) adapterView.getAdapter().getItem(i);
            ViewGroup vg= (ViewGroup) textView.getParent();
            setETsForUnits(ingr.getMeasureUnit(),ingr.getMeasureValue(),ingr.getDefaultUnit(),ingr.getDefaultValue(),vg);
        }
    });
    return textView;
}
项目:HealthHelp    文件:NovoAtendimentoActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_novo_atendimento);
    initToolbar();

    instituicao = (AutoCompleteTextView) findViewById(R.id.autoCompleteLocalAtendimento);
    profissional = (AutoCompleteTextView) findViewById(R.id.autoCompleteProfissionalSaude);
    dataHorario = (Button) findViewById(R.id.button_dados_data_horario_atendimento);

    //essas variáveis serão instanciadas chamando os métodos: getNomesLocaisAtendimentos e getNomesProfissionais.
    String[] instituicoes = new String[]{"Hospital das Clínicas", "Hospinal Santa Genoveva",
        "Hospital HGG", "Hospital do Cancer", "Novo Hospital"};
    String[] profissionais = new String[]{"João não sei das quantas", "José Maria",
        "Açogueiro do pará", "Médico bom", "Enfermeiro"};

    instituicao.setAdapter(adapter(instituicoes));
    profissional.setAdapter(adapter(profissionais));
}
项目:foodfeed    文件:UserSearchActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_user_search);

    getUserList();

    Toolbar toolbar = (Toolbar) findViewById(R.id.usersearchtoolbar);
    setSupportActionBar(toolbar);

    applicationContext = this.getApplicationContext();

    searchEt = (AutoCompleteTextView) findViewById(R.id.usersearchtext);
    mRecyclerView = (RecyclerView) findViewById(R.id.usersearchrecyclerview);
    mRecyclerView.setVisibility(View.GONE);

    progressWheel = (ProgressWheel) findViewById(R.id.usersearchprogresswheel);
    progressWheel.setVisibility(View.GONE);

    mRecyclerView.setHasFixedSize(true);
    mAdapter = new FollowAdapter(results, applicationContext);;
    mRecyclerView.setAdapter(mAdapter);
    mLayoutManager = new LinearLayoutManager(this);
    mRecyclerView.setLayoutManager(mLayoutManager);
}
项目:foodfeed    文件:SearchActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_search);

    getFoodList();

    Toolbar toolbar = (Toolbar) findViewById(R.id.searchtoolbar);
    setSupportActionBar(toolbar);

    applicationContext = this.getApplicationContext();

    searchEt = (AutoCompleteTextView) findViewById(R.id.searchtext);
    mRecyclerView = (RecyclerView) findViewById(R.id.searchrecyclerview);
    mRecyclerView.setVisibility(View.GONE);

    progressWheel = (ProgressWheel) findViewById(R.id.searchprogresswheel);
    progressWheel.setVisibility(View.GONE);

    mRecyclerView.setHasFixedSize(true);
    mAdapter = new MainFeedAdapter(results, applicationContext);;
    mRecyclerView.setAdapter(mAdapter);
    mLayoutManager = new LinearLayoutManager(this);
    mRecyclerView.setLayoutManager(mLayoutManager);
}
项目:chameleon    文件:ViewStyler.java   
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();
}
项目:ChipLayout    文件:ChipLayout.java   
private AutoCompleteTextView createAutoCompleteTextView(Context context) {
    final LayoutParams lparamsTextView = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    lparamsTextView.setMargins(0, 0, 10, 0);
    lparamsTextView.gravity = Gravity.CENTER;
    final AutoCompleteTextView autoCompleteTextView = new AutoCompleteTextView(context);
    autoCompleteTextView.setBackgroundColor(Color.parseColor("#00FFFFFF"));
    autoCompleteTextView.setLayoutParams(lparamsTextView);
    autoCompleteTextView.setHint(" ");
    autoCompleteTextView.setPadding(10,0,10,10);
    autoCompleteTextView.setSingleLine(true);
    autoCompleteTextView.setTextColor(textColor);
    autoCompleteTextView.setHintTextColor(hintColor);
    autoCompleteTextView.setCursorVisible(true);

    return autoCompleteTextView;
}
项目:ChipLayout    文件:ChipLayout.java   
private void onLayoutClick(){
    int totalChips = this.getChildCount() - 1;
    if(totalChips < 0){
        createNewChipLayout(null);
    }else{
        AutoCompleteTextView autoCompleteTextView = (AutoCompleteTextView) ((ViewGroup)this.getChildAt(totalChips)).getChildAt(labelPosition);
        if(autoCompleteTextView.isFocusable()){
            autoCompleteTextView.requestFocus();
            InputMethodManager inputMethodManager=(InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE);
            inputMethodManager.toggleSoftInputFromWindow(autoCompleteTextView.getApplicationWindowToken(), InputMethodManager.SHOW_FORCED, 0);
        }else{
            createNewChipLayout(null);
        }
    }

}
项目:fetlife-oss    文件:LoginFragment.java   
/**
 * Called to have the fragment instantiate its user interface view.
 * This is optional, and non-graphical fragments can return null (which
 * is the default implementation).  This will be called between
 * {@link #onCreate(Bundle)} and {@link #onActivityCreated(Bundle)}.
 * <p/>
 * <p>If you return a View from here, you will later be called in
 * {@link #onDestroyView} when the view is being released.
 *
 * @param inflater           The LayoutInflater object that can be used to inflate
 *                           any views in the fragment,
 * @param container          If non-null, this is the parent view that the fragment's
 *                           UI should be attached to.  The fragment should not add the view itself,
 *                           but this can be used to generate the LayoutParams of the view.
 * @param savedInstanceState If non-null, this fragment is being re-constructed
 *                           from a previous saved state as given here.
 * @return Return the View for the fragment's UI, or null.
 */
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    setRootView(inflate(inflater, container, R.layout.fragment_login));
    emailField = (AutoCompleteTextView) getRootView().findViewById(R.id.login_email);
    pwdField = (EditText) getRootView().findViewById(R.id.login_pwd);
    pwdLayout = (TextInputLayout) getRootView().findViewById(R.id.login_pwd_layout);
    ((TextView) getRootView().findViewById(R.id.login_version)).setText(BuildConfig.VERSION_NAME);
    setOnClickListeners(R.id.login_btn_ok);

    try{
        final ArrayList<String> existingAccountNames = new ArrayList<>();
        for(Account account : FetLife.getAccountManager().getAccounts())
            existingAccountNames.add(account.name);

        emailField.setAdapter(new ArrayAdapter<>(
                getActivity(), android.R.layout.simple_dropdown_item_1line, existingAccountNames));
    } catch (NoAccountsException e) {
        // no-op?
    }

    return getRootView();
}
项目:FakeGPS    文件:FakeLocation.java   
public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.fake_location);

        fake_info = (TextView) findViewById(R.id.fake_info);
        fake_info
                .setText("开始模拟,在下面的地址填写GPS记录文件与速率!\n" + "可能的位置:"
                        + Environment.getExternalStorageDirectory()
                        + "/FakeGPS/GPS.db");

        // Get a reference to the AutoCompleteTextView in the layout
        dbfile = (AutoCompleteTextView) findViewById(R.id.dbfile);
        // Get the string array
        String[] dbs = getResources().getStringArray(R.array.db_array);
        // Create the adapter and set it to the AutoCompleteTextView
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1, dbs);
        dbfile.setAdapter(adapter);

        rate_v = (EditText) findViewById(R.id.edit_text);

    }
项目:xowa_android    文件:EditSummaryFragment.java   
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    editSummaryContainer = inflater.inflate(R.layout.fragment_preview_summary, container, false);
    summaryText = (AutoCompleteTextView) editSummaryContainer.findViewById(R.id.edit_summary_edit);

    // Explicitly enable standard dictionary autocompletion in the edit summary box
    // We should be able to do this in the XML, but doing it there doesn't work. Thanks Android!
    summaryText.setInputType(summaryText.getInputType() & (~EditorInfo.TYPE_TEXT_FLAG_AUTO_COMPLETE));

    // ...so that clicking the "Done" button on the keyboard will have the effect of
    // clicking the "Next" button in the actionbar:
    summaryText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) {
            if ((keyEvent != null
                    && (keyEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER))
                    || (actionId == EditorInfo.IME_ACTION_DONE)) {
                parentActivity.clickNextButton();
            }
            return false;
        }
    });

    return editSummaryContainer;
}
项目:SkyWay-MultiParty-Android    文件:LoginActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);

    // Set up the login form.
    mRoomView = (AutoCompleteTextView) findViewById(R.id.room);
    {
        Button button = (Button) findViewById(R.id.sign_in_button);
        button.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                String strRoomId = mRoomView.getEditableText().toString();

                Context context = getApplicationContext();
                Intent intent = new Intent();
                intent.setClass(context, MultiPartyActivity.class);
                intent.putExtra(MultiPartyActivity.EXTRA_ROOM_NAME, strRoomId);

                startActivity(intent);
            }
        });
    }

}
项目:DialogUtil    文件:MaterialDialog.java   
public void setContentView(View contentView) {
    ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    contentView.setLayoutParams(layoutParams);
    if (contentView instanceof ListView) {
        setListViewHeightBasedOnChildren((ListView) contentView);
    }
    LinearLayout linearLayout = (LinearLayout) mAlertDialogWindow.findViewById(
            R.id.message_content_view);
    if (linearLayout != null) {
        linearLayout.removeAllViews();
        linearLayout.addView(contentView);
    }
    for (int i = 0; i < (linearLayout != null ? linearLayout.getChildCount() : 0); i++) {
        if (linearLayout.getChildAt(i) instanceof AutoCompleteTextView) {
            AutoCompleteTextView autoCompleteTextView
                    = (AutoCompleteTextView) linearLayout.getChildAt(i);
            autoCompleteTextView.setFocusable(true);
            autoCompleteTextView.requestFocus();
            autoCompleteTextView.setFocusableInTouchMode(true);
        }
    }
}
项目:StudyBox_Android    文件:DecksSearch.java   
public void setSearchable(Context context, Menu menu) {
    searchItem = menu.findItem(R.id.action_search);
    searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    searchTextView = (AutoCompleteTextView) searchView.findViewById(R.id.search_src_text);

    searchManager = (SearchManager) context.getSystemService(Context.SEARCH_SERVICE);
    searchView.setSearchableInfo(searchManager.getSearchableInfo(
            new ComponentName(context, DecksActivity.class)));

    searchView.setOnQueryTextListener(this);
    searchView.setIconifiedByDefault(true);
    searchView.setMaxWidth(MAX_WIDTH);

    setLengthLimit(MAX_LENGTH);
    setOnCloseClick();
    setOnMenuItemExpand();
    restoreState();
}
项目:Android-Clearable-EditText-Library    文件:ClearableEditText.java   
private void initViews() {
    mTextInputLayout = (TextInputLayout) mView.findViewById(R.id.textinputlayout);

    mClearButton = (Button) mView.findViewById(R.id.clear_button);
    mClearButton.setVisibility(GONE);

    mAutoCompleteTextView = (AutoCompleteTextView) mView.findViewById(R.id.autocompletetextview);
}
项目:GitHub    文件:PoiAroundSearchActivity.java   
private void setup() {
    mSearchText = (AutoCompleteTextView) findViewById(R.id.etInput);
    mSearchText.addTextChangedListener(this);
    mSearchText.setHint(getString(R.string.search_map));
    findViewById(R.id.search_back).setOnClickListener(view -> {
        finish();
    });
    mSearchText.setOnEditorActionListener((textView, i, keyEvent) -> {
        if (i == EditorInfo.IME_ACTION_SEARCH) {
            doSearch();
        }
        return false;
    });
}
项目:pius1    文件:MaterialDialog.java   
public void setContentView(View contentView)
{
           ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(
    ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
           contentView.setLayoutParams(layoutParams);
           if (contentView instanceof ListView)
    {
               setListViewHeightBasedOnChildren((ListView) contentView);
           }
           LinearLayout linearLayout = (LinearLayout) mAlertDialogWindow.findViewById(
    R.id.message_content_view);
           if (linearLayout != null)
    {
               linearLayout.removeAllViews();
               linearLayout.addView(contentView);
           }
           for (int i = 0; i < (linearLayout != null ? linearLayout.getChildCount() : 0); i++)
    {
               if (linearLayout.getChildAt(i) instanceof AutoCompleteTextView)
    {
                   AutoCompleteTextView autoCompleteTextView
        = (AutoCompleteTextView) linearLayout.getChildAt(i);
                   autoCompleteTextView.setFocusable(true);
                   autoCompleteTextView.requestFocus();
                   autoCompleteTextView.setFocusableInTouchMode(true);
               }
           }
       }
项目:Fahrplan    文件:MainActivity.java   
private void fillToWithTakeMeHome() {
    String home = setting.getSettings(R.string.setting_key_take_me_home, "");
    if(home.isEmpty()) {
        Toast.makeText(this, this.getResources().getText(R.string.error_missing_take_me_home), Toast.LENGTH_LONG).show();
    } else {
        AutoCompleteTextView toText = (AutoCompleteTextView) findViewById(R.id.input_to);
        toText.setText(home, false);
    }
}
项目:Fahrplan    文件:MainActivity.java   
private void startChangeDirection() {
    AutoCompleteTextView fromText = (AutoCompleteTextView) findViewById(R.id.input_from);
    String bufferFrom = fromText.getText().toString();

    AutoCompleteTextView toText = (AutoCompleteTextView) findViewById(R.id.input_to);
    String bufferTo = toText.getText().toString();

    fromText.setText(bufferTo, false);
    toText.setText(bufferFrom, false);
}
项目:Fahrplan    文件:MainActivity.java   
public void activateFavorite(int position) {
    FavoriteModelItem fav = favorite.get(position);
    AutoCompleteTextView fromText = (AutoCompleteTextView) findViewById(R.id.input_from);
    AutoCompleteTextView toText = (AutoCompleteTextView) findViewById(R.id.input_to);
    fromText.setText(fav.getFrom(), false);
    toText.setText(fav.getTo(), false);
}