List of usage examples for android.widget Spinner setAdapter
@Override public void setAdapter(SpinnerAdapter adapter)
From source file:com.manning.androidhacks.hack017.CreateAccountAdapter.java
private void populateSecondForm(LinearLayout formLayout) { formLayout.addView(createTitle(mContext.getString(R.string.account_create_password_title))); EditText passwordEditText = createEditText(mContext.getString(R.string.account_create_password_hint), InputType.TYPE_CLASS_TEXT, EditorInfo.IME_ACTION_DONE, false, PASSWORD_KEY); passwordEditText.setTransformationMethod(new PasswordTransformationMethod()); formLayout.addView(passwordEditText); formLayout.addView(createErrorView(PASSWORD_KEY)); formLayout.addView(createTitle(mContext.getString(R.string.account_create_gender_title))); Spinner spinner = new Spinner(mContext); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);/*from www. j a v a2 s . c om*/ params.bottomMargin = 17; spinner.setLayoutParams(params); final ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(mContext, R.array.sexes_array, android.R.layout.simple_spinner_item); spinner.setAdapter(adapter); spinner.setPrompt(mContext.getString(R.string.account_create_sex_spinner_prompt)); spinner.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { mFormData.put(GENDER_KEY, adapter.getItem(pos).toString()); } @Override public void onNothingSelected(AdapterView<?> arg0) { } }); if (mFormData.get(GENDER_KEY) != null) { spinner.setSelection(adapter.getPosition(mFormData.get(GENDER_KEY))); } formLayout.addView(spinner); }
From source file:com.github.michalbednarski.intentslab.browser.ComponentFetcher.java
@Override void initConfigurationForm(final FetcherOptionsDialog dialog) { // Disable development permission checkbox if it's not available if (!DEVELOPMENT_PERMISSIONS_SUPPORTED) { dialog.findView(R.id.permission_filter_development).setEnabled(false); }//www . ja v a2 s . c om // Prepare protection preset spinner { // Find current preset int currentPresetId = PROTECTION_PRESETS.length; // "Custom" if nothing found if (!testWritePermissionForProviders) { for (int i = 0; i < PROTECTION_PRESETS.length; i++) { if (protection == PROTECTION_PRESETS[i]) { currentPresetId = i; dialog.findView(R.id.permission_filter_details).setVisibility(View.GONE); break; } } } // Fill spinner Spinner protectionPresetSpinner = (Spinner) dialog.findView(R.id.permission_filter_spinner); Activity activity = dialog.getActivity(); protectionPresetSpinner .setAdapter(new ArrayAdapter<String>(activity, android.R.layout.simple_spinner_item, new String[] { activity.getString(R.string.permission_filter_show_all), // 0 activity.getString(R.string.permission_filter_show_exported), // 1 activity.getString(R.string.permission_filter_show_obtainable), // 2 activity.getString(R.string.permission_filter_world_accessible), // 3 activity.getString(R.string.filter_custom) // 4 })); protectionPresetSpinner.setSelection(currentPresetId); // Set up spinner event protectionPresetSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { boolean isCustom = position == PROTECTION_PRESETS.length; if (!isCustom) { int preset = PROTECTION_PRESETS[position]; dialog.setBoxChecked(R.id.permission_filter_world_accessible, (preset & PROTECTION_WORLD_ACCESSIBLE) != 0); dialog.setBoxChecked(R.id.permission_filter_normal, (preset & PROTECTION_NORMAL) != 0); dialog.setBoxChecked(R.id.permission_filter_dangerous, (preset & PROTECTION_DANGEROUS) != 0); dialog.setBoxChecked(R.id.permission_filter_signature, (preset & PROTECTION_SIGNATURE) != 0); dialog.setBoxChecked(R.id.permission_filter_system, (preset & PROTECTION_SYSTEM) != 0); dialog.setBoxChecked(R.id.permission_filter_development, (preset & PROTECTION_DEVELOPMENT) != 0); dialog.setBoxChecked(R.id.permission_filter_unexported, (preset & PROTECTION_UNEXPORTED) != 0); dialog.setBoxChecked(R.id.permission_filter_unknown, (preset & PROTECTION_UNKNOWN) != 0); dialog.setBoxChecked(R.id.read_permission, true); } dialog.findView(R.id.permission_filter_details) .setVisibility(isCustom ? View.VISIBLE : View.GONE); } @Override public void onNothingSelected(AdapterView<?> parent) { // Spinner cannot have nothing selected } }); } // Fill form dialog.setBoxChecked(R.id.system_apps, (appType & APP_TYPE_SYSTEM) != 0); dialog.setBoxChecked(R.id.user_apps, (appType & APP_TYPE_USER) != 0); dialog.setBoxChecked(R.id.activities, (type & PackageManager.GET_ACTIVITIES) != 0); dialog.setBoxChecked(R.id.receivers, (type & PackageManager.GET_RECEIVERS) != 0); dialog.setBoxChecked(R.id.services, (type & PackageManager.GET_SERVICES) != 0); dialog.setBoxChecked(R.id.content_providers, (type & PackageManager.GET_PROVIDERS) != 0); dialog.setBoxChecked(R.id.permission_filter_world_accessible, (protection & PROTECTION_WORLD_ACCESSIBLE) != 0); dialog.setBoxChecked(R.id.permission_filter_normal, (protection & PROTECTION_NORMAL) != 0); dialog.setBoxChecked(R.id.permission_filter_dangerous, (protection & PROTECTION_DANGEROUS) != 0); dialog.setBoxChecked(R.id.permission_filter_signature, (protection & PROTECTION_SIGNATURE) != 0); dialog.setBoxChecked(R.id.permission_filter_system, (protection & PROTECTION_SYSTEM) != 0); dialog.setBoxChecked(R.id.permission_filter_development, (protection & PROTECTION_DEVELOPMENT) != 0); dialog.setBoxChecked(R.id.permission_filter_unexported, (protection & PROTECTION_UNEXPORTED) != 0); dialog.setBoxChecked(R.id.permission_filter_unknown, (protection & PROTECTION_UNKNOWN) != 0); dialog.setBoxChecked(testWritePermissionForProviders ? R.id.write_permission : R.id.read_permission, true); dialog.setBoxChecked(R.id.only_providers_with_grant_uri_permission, includeOnlyProvidersAllowingPermissionGranting); dialog.setBoxChecked(R.id.metadata, requireMetaDataSubstring != null); dialog.setTextInField(R.id.metadata_substring, requireMetaDataSubstring); // Set up sections showing when their checkboxes are checked dialog.findView(R.id.content_provider_permission_type) .setVisibility(testWritePermissionForProviders ? View.VISIBLE : View.GONE); dialog.findView(R.id.content_provider_options) .setVisibility((type & PackageManager.GET_PROVIDERS) != 0 ? View.VISIBLE : View.GONE); ((CheckBox) dialog.findView(R.id.content_providers)) .setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { dialog.findView(R.id.content_provider_permission_type) .setVisibility(isChecked ? View.VISIBLE : View.GONE); dialog.findView(R.id.content_provider_options) .setVisibility(isChecked ? View.VISIBLE : View.GONE); if (!isChecked) { dialog.setBoxChecked(R.id.read_permission, true); dialog.setBoxChecked(R.id.only_providers_with_grant_uri_permission, false); } } }); dialog.findView(R.id.metadata_details) .setVisibility(requireMetaDataSubstring != null ? View.VISIBLE : View.GONE); ((CheckBox) dialog.findView(R.id.metadata)) .setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { dialog.findView(R.id.metadata_details).setVisibility(isChecked ? View.VISIBLE : View.GONE); if (!isChecked) { dialog.setTextInField(R.id.metadata_substring, ""); } } }); }
From source file:com.microsoft.identity.client.testapp.MainActivity.java
@Override public void bindSelectAccountSpinner(Spinner selectUser) { final ArrayAdapter<String> userAdapter = new ArrayAdapter<>(getApplicationContext(), android.R.layout.simple_spinner_item, new ArrayList<String>() { {/*from w w w .java2 s. c o m*/ for (IAccount account : mApplication.getAccounts()) add(account.getUsername()); } }); userAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); selectUser.setAdapter(userAdapter); }
From source file:com.teddoll.movies.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); final MenuItem sort = menu.findItem(R.id.menu_list_select); Spinner spinner = (Spinner) MenuItemCompat.getActionView(sort); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.sort_array, R.layout.item_action_bar_spinner); adapter.setDropDownViewResource(R.layout.item_action_bar_spinner_item); spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override// w w w . j ava 2 s.c o m public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { sort(position); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); spinner.setAdapter(adapter); spinner.setSelection(this.sort.ordinal()); return true; }
From source file:li.klass.fhem.fragments.TimerDetailFragment.java
private void createTimerTypeSpinner(View view) { Spinner typeSpinner = getTypeSpinner(view); ArrayAdapter<String> timerTypeAdapter = new ArrayAdapter<>(getActivity(), R.layout.spinnercontent); for (AtDevice.TimerType type : AtDevice.TimerType.values()) { timerTypeAdapter.add(view.getContext().getString(type.getText())); }//from ww w . j a v a2s. co m typeSpinner.setAdapter(timerTypeAdapter); typeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { TimerDetailFragment.this.type = AtDevice.TimerType.values()[i]; } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); }
From source file:eu.operando.proxy.filters.domain.DomainFiltersActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { setTheme(MainContext.INSTANCE.getSettings().getThemeStyle().themeAppCompatStyle()); updateFiltersList();/*from w w w .j a v a 2 s . c o m*/ super.onCreate(savedInstanceState); setContentView(R.layout.filters_content); ButterKnife.inject(this); userDomainFiltersAdapter = new UserDomainFiltersAdapter(); externalDomainFiltersAdapter = new ExternalDomainFiltersAdapter(); recyclerView = new RecyclerView(this); recyclerView.setLayoutManager(new LinearLayoutManager(this)); //recyclerView.setAdapter(userDomainFiltersAdapter); //recyclerViewHolder.addView(recyclerView); //Setup Toolbar Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setHomeButtonEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); View spinnerContainer = LayoutInflater.from(this).inflate(R.layout.toolbar_spinner, toolbar, false); ActionBar.LayoutParams lp = new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); toolbar.addView(spinnerContainer, lp); DomainFiltersSpinnerAdapter spinnerAdapter = new DomainFiltersSpinnerAdapter(); Spinner spinner = (Spinner) spinnerContainer.findViewById(R.id.toolbar_spinner); spinner.setAdapter(spinnerAdapter); spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { viewSelected = position; recyclerViewHolder.removeAllViews(); //recyclerViewHolder.invalidate(); switch (position) { case 0: recyclerView.setAdapter(userDomainFiltersAdapter); break; case 1: recyclerView.setAdapter(externalDomainFiltersAdapter); break; default: recyclerView.setAdapter(userDomainFiltersAdapter); break; } recyclerViewHolder.addView(recyclerView); inValidateSelections(); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); } }
From source file:eu.operando.operandoapp.filters.domain.DomainFiltersActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { setTheme(MainContext.INSTANCE.getSettings().getThemeStyle().themeAppCompatStyle()); updateFiltersList();//w ww . j av a 2 s . c om super.onCreate(savedInstanceState); setContentView(R.layout.filters_content); ButterKnife.inject(this); userDomainFiltersAdapter = new UserDomainFiltersAdapter(); externalDomainFiltersAdapter = new ExternalDomainFiltersAdapter(); recyclerView = new RecyclerView(this); recyclerView.setLayoutManager(new LinearLayoutManager(this)); //recyclerView.setAdapter(userDomainFiltersAdapter); //recyclerViewHolder.addView(recyclerView); //region Setup Toolbar Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setHomeButtonEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); View spinnerContainer = LayoutInflater.from(this).inflate(R.layout.toolbar_spinner, toolbar, false); ActionBar.LayoutParams lp = new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); toolbar.addView(spinnerContainer, lp); DomainFiltersSpinnerAdapter spinnerAdapter = new DomainFiltersSpinnerAdapter(); Spinner spinner = (Spinner) spinnerContainer.findViewById(R.id.toolbar_spinner); spinner.setAdapter(spinnerAdapter); spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { viewSelected = position; recyclerViewHolder.removeAllViews(); //recyclerViewHolder.invalidate(); switch (position) { case 0: recyclerView.setAdapter(userDomainFiltersAdapter); break; case 1: recyclerView.setAdapter(externalDomainFiltersAdapter); break; default: recyclerView.setAdapter(userDomainFiltersAdapter); break; } recyclerViewHolder.addView(recyclerView); inValidateSelections(); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); } //endregion }
From source file:com.bringcommunications.etherpay.SendActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); overlay_frame_layout = new FrameLayout(getApplicationContext()); setContentView(overlay_frame_layout); ///*www .j ava 2 s .c om*/ context = this; hex = new Hex(); preferences = getSharedPreferences("etherpay.bringcommunications.com", MODE_PRIVATE); private_key = preferences.getString("key", private_key); acct_addr = preferences.getString("acct_addr", acct_addr); long wei_balance = preferences.getLong("balance", 0); eth_balance = (float) wei_balance / Util.WEI_PER_ETH; price = preferences.getFloat("price", price); show_gas = preferences.getBoolean("show_gas", show_gas); show_data = preferences.getBoolean("show_data", show_data); boolean denomination_eth = preferences.getBoolean("denomination_eth", true); System.out.println("denomination_eth is " + denomination_eth); denomination = denomination_eth ? Denomination.ETH : Denomination.FINNEY; auto_pay = getIntent().getStringExtra("AUTO_PAY"); to_addr = getIntent().getStringExtra("TO_ADDR"); String size_str = getIntent().getStringExtra("SIZE"); eth_size = Float.valueOf(size_str); data = getIntent().getStringExtra("DATA"); send_is_done = false; // View activity_send_view = getLayoutInflater().inflate(R.layout.activity_send, overlay_frame_layout, false); setContentView(activity_send_view); // Spinner dropdown = (Spinner) findViewById(R.id.denomination); String[] items = new String[] { "ETH", "Finney" }; ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, items); dropdown.setSelection((denomination == Denomination.ETH) ? 0 : 1); dropdown.setOnItemSelectedListener(this); dropdown.setAdapter(adapter); // Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); String app_name = getResources().getString(R.string.app_name); toolbar.setTitle(app_name); toolbar.setSubtitle("Send Payment"); toolbar.setBackgroundResource(R.color.color_toolbar); setSupportActionBar(toolbar); // TextView to_addr_view = (TextView) findViewById(R.id.to_addr); to_addr_view.setText(to_addr); // TextView size_view = (TextView) findViewById(R.id.size); size_str = (denomination == Denomination.ETH) ? String.format("%1.03f", eth_size) : String.format("%03d", (int) (eth_size * 1000 + 0.5)); size_view.setText(size_str); // LinearLayout gas_layout = (LinearLayout) findViewById(R.id.gas_layout); TextView gas_prompt_view = (TextView) findViewById(R.id.gas_prompt); TextView gas_view = (TextView) findViewById(R.id.gas); ImageButton gas_help_view = (ImageButton) findViewById(R.id.gas_help); if (show_gas) { String gas_str = String.format("%7d", gas_limit); gas_view.setText(gas_str); gas_layout.setVisibility(View.VISIBLE); gas_prompt_view.setVisibility(View.VISIBLE); gas_help_view.setVisibility(View.VISIBLE); gas_view.setVisibility(View.VISIBLE); } else { gas_layout.setVisibility(View.GONE); gas_prompt_view.setVisibility(View.GONE); gas_help_view.setVisibility(View.GONE); gas_view.setVisibility(View.GONE); } LinearLayout data_layout = (LinearLayout) findViewById(R.id.data_layout); TextView data_prompt_view = (TextView) findViewById(R.id.data_prompt); TextView data_view = (TextView) findViewById(R.id.data); ImageButton data_help_view = (ImageButton) findViewById(R.id.data_help); if (show_data) { data_view.setText(data); data_layout.setVisibility(View.VISIBLE); data_prompt_view.setVisibility(View.VISIBLE); data_help_view.setVisibility(View.VISIBLE); data_view.setVisibility(View.VISIBLE); } else { data = ""; data_layout.setVisibility(View.GONE); data_prompt_view.setVisibility(View.GONE); data_help_view.setVisibility(View.GONE); data_view.setVisibility(View.GONE); } // //sanity check if (to_addr.length() != 42) { this.finish(); } }
From source file:ch.dbrgn.android.simplerepost.activities.RepostActivity.java
/*** Menu ***/ @Override//from w w w.jav a 2 s . co m public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_repost, menu); // Get spinner MenuItem item = menu.findItem(R.id.spinner_style); Spinner spinner = (Spinner) MenuItemCompat.getActionView(item); // Prepare data String[] spinnerArray = new String[Config.REPOST_STYLES.size()]; Iterator<String> styleIterator = Config.REPOST_STYLES.keySet().iterator(); for (int i = 0; i < Config.REPOST_STYLES.size(); i++) { spinnerArray[i] = styleIterator.next(); } // Set adapter ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, spinnerArray); spinner.setAdapter(adapter); // Handle clicks spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { // Fix text color CheckedTextView textView = (CheckedTextView) view; textView.setTextColor(Color.WHITE); // Update watermark int style = (int) Config.REPOST_STYLES.values().toArray()[position]; updateWatermark(style); } @Override public void onNothingSelected(AdapterView<?> arg0) { } }); return true; }
From source file:org.mythtv.client.ui.MainMenuFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View mainMenuView = inflater.inflate(R.layout.fragment_main_menu, container, false); ToggleButton toggleIsAway = (ToggleButton) mainMenuView.findViewById(R.id.toggleButtonIsAway); toggleIsAway.setOnCheckedChangeListener(this.homeAwayCheckedChanged); // set version string - we only do this to prepend the 'V' TextView tView = (TextView) mainMenuView.findViewById(R.id.textview_mainmenu_version); tView.setText("V" + this.getString(R.string.app_version)); // set frontends spinner Spinner spinner = (Spinner) mainMenuView.findViewById(R.id.spinner_frontends); spinner.setAdapter(adapter); spinner.setOnItemSelectedListener(this); // set preference button click listener ImageButton prefButton = (ImageButton) mainMenuView.findViewById(R.id.imagebutton_main_menu_preferences); prefButton.setOnClickListener(this.preferenceButtonOnClick); // set mythmote button click listener ImageButton mmButton = (ImageButton) mainMenuView.findViewById(R.id.imagebutton_main_menu_mythmote); mmButton.setOnClickListener(this.mythmoteButtonOnClick); // set activities button click listeners Button aBtn = (Button) mainMenuView.findViewById(R.id.button_main_menu_guide); aBtn.setOnClickListener(this.activityButtonOnClick); aBtn = (Button) mainMenuView.findViewById(R.id.button_main_menu_music); aBtn.setOnClickListener(this.activityButtonOnClick); aBtn = (Button) mainMenuView.findViewById(R.id.button_main_menu_pictures); aBtn.setOnClickListener(this.activityButtonOnClick); aBtn = (Button) mainMenuView.findViewById(R.id.button_main_menu_recording_rules); aBtn.setOnClickListener(this.activityButtonOnClick); aBtn = (Button) mainMenuView.findViewById(R.id.button_main_menu_recordings); aBtn.setOnClickListener(this.activityButtonOnClick); aBtn = (Button) mainMenuView.findViewById(R.id.button_main_menu_upcoming); aBtn.setOnClickListener(this.activityButtonOnClick); aBtn = (Button) mainMenuView.findViewById(R.id.button_main_menu_videos); aBtn.setOnClickListener(this.activityButtonOnClick); return mainMenuView; }