当前位置: 首页>>代码示例>>Java>>正文


Java AutoCompleteTextView.setAdapter方法代码示例

本文整理汇总了Java中android.widget.AutoCompleteTextView.setAdapter方法的典型用法代码示例。如果您正苦于以下问题:Java AutoCompleteTextView.setAdapter方法的具体用法?Java AutoCompleteTextView.setAdapter怎么用?Java AutoCompleteTextView.setAdapter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.AutoCompleteTextView的用法示例。


在下文中一共展示了AutoCompleteTextView.setAdapter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
@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);
}
 
开发者ID:Jamjomjara,项目名称:snu-artoon,代码行数:26,代码来源:MainActivity.java

示例2: onCreate

import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
@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);
}
 
开发者ID:IMSmobile,项目名称:Fahrplan,代码行数:23,代码来源:MainActivity.java

示例3: onCreate

import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
@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);
}
 
开发者ID:IMSmobile,项目名称:Fahrplan,代码行数:26,代码来源:SettingActivity.java

示例4: 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

示例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) {

		}

	});

	getUrl.setSelectAllOnFocus(true);
	mSearchAdapter = new SearchAdapter(mActivity, mDarkTheme, isIncognito());
	getUrl.setAdapter(mSearchAdapter);
}
 
开发者ID:Louis19910615,项目名称:youkes_browser,代码行数:23,代码来源:BrowserActivity.java

示例6: PlaceAutoCompleteHelper

import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
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);
}
 
开发者ID:agusibrahim,项目名称:go-jay,代码行数:17,代码来源:PlaceAutoCompleteHelper.java

示例7: onCreate

import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
@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));
}
 
开发者ID:Yuri-M-Dias,项目名称:HealthHelp,代码行数:20,代码来源:NovoAtendimentoActivity.java

示例8: onCreate

import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
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);

	}
 
开发者ID:wuwenjie1992,项目名称:FakeGPS,代码行数:24,代码来源:FakeLocation.java

示例9: createNewTextView

import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
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;
}
 
开发者ID:bounswe,项目名称:bounswe2016group2,代码行数:18,代码来源:FoodAddFragment.java

示例10: onCreateView

import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
/**
 * 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();
}
 
开发者ID:xcjs,项目名称:fetlife-oss,代码行数:42,代码来源:LoginFragment.java

示例11: showAddTagDialog

import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
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();
}
 
开发者ID:nmud,项目名称:nmud,代码行数:25,代码来源:EntityFragment.java

示例12: 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

示例13: loadStationsSuccess

import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
private Response.Listener<JSONArray> loadStationsSuccess() {
    return new Response.Listener<JSONArray>() {
        @Override
        public void onResponse(JSONArray response) {
            try {
                if (response.length() == 0) {
                    Toast.makeText(FindConnectionActivity.this, TAG + ": " + "No available connections", Toast.LENGTH_LONG).show();
                } else {
                    ArrayList<String> stations = new ArrayList<>();

                    for (int i = 0; i < response.length(); i++) {
                        stations.add(response.getJSONObject(i).getString("name"));
                    }

                    // Put values into autocomplete text views.

                    // From autocomplete.
                    ArrayAdapter<String> fromAdapter = new ArrayAdapter<String>(FindConnectionActivity.this,
                            android.R.layout.simple_dropdown_item_1line, stations);
                    AutoCompleteTextView fromTextView = (AutoCompleteTextView) findViewById(R.id.fromAutocomplete);
                    fromTextView.setAdapter(fromAdapter);

                    // To autocomplete.
                    ArrayAdapter<String> toAdapter = new ArrayAdapter<String>(FindConnectionActivity.this,
                            android.R.layout.simple_dropdown_item_1line, stations);
                    AutoCompleteTextView toTextView = (AutoCompleteTextView) findViewById(R.id.toAutocomplete);
                    toTextView.setAdapter(toAdapter);
                }
            } catch (JSONException e) {
                Toast.makeText(FindConnectionActivity.this, TAG + ": " + e.getMessage(), Toast.LENGTH_SHORT).show();
            }
        }
    };

}
 
开发者ID:trvlrch,项目名称:trvlr-android,代码行数:36,代码来源:FindConnectionActivity.java

示例14: initComponent

import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
private void initComponent() {
    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addApi(Places.GEO_DATA_API)
            .addConnectionCallbacks(this)
            .enableAutoManage(this, this)
            .addOnConnectionFailedListener(this)
            .build();
    btnFind = (Button) findViewById(R.id.findPlace);
    placeToGo = (AutoCompleteTextView) findViewById(R.id.inputPlace);
    mAdapter = new PlaceAutoCompleteAdapter(this, android.R.layout.simple_list_item_1, mGoogleApiClient, BOUNDS_HCMC, null);
    placeToGo.setAdapter(mAdapter);
    setAutoSuggestion();

    btnFind.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!placeToGo.getText().toString().equals("")) {
                moveToPosition();
                placeToGo.setText("");
            }
            else Toast.makeText(MapsActivity2.this, "Please input a place", Toast.LENGTH_SHORT).show();
            InputMethodManager inputManager = (InputMethodManager)
                    getSystemService(Context.INPUT_METHOD_SERVICE);

            inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
                    InputMethodManager.HIDE_NOT_ALWAYS);
        }
    });


}
 
开发者ID:LewisVo,项目名称:Overkill,代码行数:32,代码来源:MapsActivity2.java

示例15: 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


注:本文中的android.widget.AutoCompleteTextView.setAdapter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。