本文整理了Java中android.widget.Spinner
类的一些代码示例,展示了Spinner
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Spinner
类的具体详情如下:
包路径:android.widget.Spinner
类名称:Spinner
暂无
代码示例来源:origin: stackoverflow.com
((TextView)v.findViewById(android.R.id.text1)).setText("");
((TextView)v.findViewById(android.R.id.text1)).setHint(getItem(getCount())); //"Hint to be displayed"
spinner.setAdapter(adapter);
spinner.setSelection(adapter.getCount()); //set the hint the default selection so it appears on launch.
spinner.setOnItemSelectedListener(this);
代码示例来源:origin: cSploit/android
private void setStartedState() {
int min = Integer.parseInt((String) mMinSpinner.getSelectedItem()), max = Integer
.parseInt((String) mMaxSpinner.getSelectedItem());
if (min > max)
max = min + 1;
mAccountFound = false;
try {
mStartButton.setImageDrawable(ContextCompat.getDrawable(getBaseContext(), R.drawable.ic_stop_24dp));
mProcess =
System.getTools().hydra
.crack(System.getCurrentTarget(),
Integer.parseInt((String) mPortSpinner
.getSelectedItem()),
(String) mProtocolSpinner.getSelectedItem(),
mCustomCharset == null ? CHARSETS_MAPPING[mCharsetSpinner
.getSelectedItemPosition()] : mCustomCharset,
min, max, (String) mUserSpinner.getSelectedItem(),
mUserWordlist, mPassWordlist, mReceiver);
mActivity.setVisibility(View.VISIBLE);
mStatusText.setTextColor(Color.DKGRAY);
mStatusText.setText(getString(R.string.starting_dots));
mRunning = true;
} catch (ChildManager.ChildNotStartedException e) {
setStoppedState();
}
}
代码示例来源:origin: stackoverflow.com
Spinner s = (Spinner)Util.findViewById(view, R.id.sound, R.id.spinner);
s.setAdapter(adapter);
s.setSelection(position, false);
s.setOnItemSelectedListener(listener);
代码示例来源:origin: stackoverflow.com
Spinner spinner = (Spinner) findViewById(R.id.spinner);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.planets_array, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setPrompt("Select your favorite Planet!");
spinner.setAdapter(
new NothingSelectedSpinnerAdapter(
adapter,
R.layout.contact_spinner_row_nothing_selected,
// R.layout.contact_spinner_nothing_selected_dropdown, // Optional
this));
代码示例来源:origin: stackoverflow.com
Spinner spinner = new Spinner(this);
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, spinnerArray); //selected item will look like a spinner set from XML
spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(spinnerArrayAdapter);
代码示例来源:origin: stackoverflow.com
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_section_contacts,
container, false);
Spinner phoneTypeSpinner = (Spinner) rootView.findViewById(R.id.contactPhoneTypeSpinner);
Button contactButton = (Button) rootView.findViewById(R.id.addContact);
final TableLayout tableLayout = (TableLayout) rootView.findViewById(R.id.contactsTableLayout);
final EditText txtContactName = (EditText) rootView.findViewById(R.id.contactName);
final EditText txtContactRelationship = (EditText) rootView.findViewById(R.id.contactRelationship);
android.R.layout.simple_spinner_item, list);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
phoneTypeSpinner.setAdapter(adapter);
phoneTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
contactButton.setOnClickListener(new View.OnClickListener() {
int rowId = 0;
@Override
tvContactName.setText(txtContactName.getText().toString());
tvRelationship.setText(txtContactRelationship.getText().toString());
tvContactNo.setText(txtContactPhoneNo.getText().toString());
代码示例来源:origin: iTXTech/Daedalus
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_dns_test, container, false);
final TextView textViewTestInfo = view.findViewById(R.id.textView_test_info);
final Spinner spinnerServerChoice = view.findViewById(R.id.spinner_server_choice);
ArrayAdapter spinnerArrayAdapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1, DNSServerHelper.getAllServers());
spinnerServerChoice.setAdapter(spinnerArrayAdapter);
spinnerServerChoice.setSelection(DNSServerHelper.getPosition(DNSServerHelper.getPrimary()));
}};
final Spinner spinnerType = view.findViewById(R.id.spinner_type);
ArrayAdapter<Type> typeAdapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1, types);
spinnerType.setAdapter(typeAdapter);
final AutoCompleteTextView textViewTestDomain = view.findViewById(R.id.autoCompleteTextView_test_url);
final Button startTestBut = view.findViewById(R.id.button_start_test);
startTestBut.setOnClickListener(v -> {
startTestBut.setEnabled(false);
InputMethodManager imm = (InputMethodManager) Daedalus.getInstance().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
textViewTestInfo.setText("");
代码示例来源:origin: stackoverflow.com
convertView = mContext.getLayoutInflater().inflate(
R.layout.brandslayout, parent, false);
convertView.setOnClickListener(new View.OnClickListener()
ProductGroupId=UrunId.getText().toString();
RackPercentage= edtText.getText().toString();
ExistsOnRack = "1";
AddProducts(Integer.parseInt( spnProductGroup.getSelectedItem().toString().split("#")[1]),Integer.parseInt(UrunId.getText().toString()));
.findViewById(R.id.BrandAdi);
final TextView UrunId = (TextView) convertView
.findViewById(R.id.BrandId);
.findViewById(R.id.tvRateIcon);
UrunAdi.setText(((Brands)Markalar.get(position)).BrandName);
UrunId.setText(((Brands)Markalar.get(position)).BrandId);
chkSelect.setVisibility(((Brands)Markalar.get(position)).deger1);
edtText.setVisibility(((Brands)Markalar.get(position)).deger2);
btnSelect.setVisibility(((Brands)Markalar.get(position)).deger3);
tvOran.setVisibility(((Brands)Markalar.get(position)).deger4);
代码示例来源:origin: ankidroid/Anki-Android
Toolbar toolbar = (Toolbar) mainView.findViewById(R.id.toolbar);
if (toolbar != null) {
setSupportActionBar(toolbar);
mCardsButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mNoteTypeSpinner.setAdapter(noteTypeAdapter);
noteTypeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
deckTextView.setText(R.string.CardEditorCardDeck);
mNoteDeckSpinner.setAdapter(noteDeckAdapter);
noteDeckAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mNoteDeckSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
mNoteTypeSpinner.setSelection(position, false);
mNoteTypeSpinner.setOnItemSelectedListener(new SetNoteTypeListener());
setTitle(R.string.cardeditor_title_add_note);
mNoteTypeSpinner.setOnItemSelectedListener(new EditNoteTypeListener());
setTitle(R.string.cardeditor_title_edit_card);
代码示例来源:origin: stackoverflow.com
final Spinner group = (Spinner)findViewById(R.id.txtGroup);
Button cost = (Button)findViewById(R.id.btnCost);
cost.setOnClickListener(new View.OnClickListener() {
final TextView result = ((TextView)findViewById(R.id.txtResult));
@Override
public void onClick(View v) {
numberOfTickets = Integer.parseInt(tickets.getText( ).toString( ));
totalCost = costPerTicket * numberOfTickets;
DecimalFormat currency = new DecimalFormat("$###,###.##");
groupChoice = group.getSelectedItem( ).toString( );
String costForString = "Cost for " + groupChoice + "is " + currency.format(totalCost);
result.setText(costForString);
代码示例来源:origin: k9mail/k-9
mSubscribedFoldersOnly = findViewById(R.id.subscribed_folders_only);
mNextButton.setOnClickListener(this);
mAuthTypeView.setAdapter(mAuthTypeAdapter);
mPortView.setKeyListener(DigitsKeyListener.getInstance("0123456789"));
mCurrentAuthTypeViewPosition = savedInstanceState.getInt(STATE_AUTH_TYPE_POSITION);
mAuthTypeView.setSelection(mCurrentAuthTypeViewPosition, false);
updateViewFromAuthType();
mUsernameView.setText(settings.username);
mPasswordView.setText(settings.password);
mSubscribedFoldersOnly.setVisibility(View.GONE);
} else if (settings.type.equals(Protocols.IMAP)) {
serverLabelView.setText(R.string.account_setup_incoming_imap_server_label);
serverLabelView.setText(R.string.account_setup_incoming_webdav_server_label);
mConnectionSecurityChoices = new ConnectionSecurity[] {
ConnectionSecurity.NONE,
mSecurityTypeView.setAdapter(securityTypesAdapter);
mSecurityTypeView.setSelection(mCurrentSecurityTypeViewPosition, false);
代码示例来源:origin: eclipse/paho.mqtt.android
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final View rootView = inflater.inflate(R.layout.fragment_publish, container, false);
EditText topicText = (EditText) rootView.findViewById(R.id.topic);
EditText messageText = (EditText) rootView.findViewById(R.id.message);
Spinner qos = (Spinner) rootView.findViewById(R.id.qos_spinner);
final Switch retain = (Switch) rootView.findViewById(R.id.retain_switch);
topicText.setText(topic);
topicText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
messageText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
qos.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
qos.setAdapter(adapter);
Button publishButton = (Button) rootView.findViewById(R.id.publish_button);
publishButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
代码示例来源:origin: seven332/EhViewer
@SuppressLint("InflateParams")
public GalleryMenuHelper(Context context) {
mView = LayoutInflater.from(context).inflate(R.layout.dialog_gallery_menu, null);
mScreenRotation = (Spinner) mView.findViewById(R.id.screen_rotation);
mReadingDirection = (Spinner) mView.findViewById(R.id.reading_direction);
mScaleMode = (Spinner) mView.findViewById(R.id.page_scaling);
mStartPosition = (Spinner) mView.findViewById(R.id.start_position);
mKeepScreenOn = (SwitchCompat) mView.findViewById(R.id.keep_screen_on);
mScreenLightness = (SeekBar) mView.findViewById(R.id.screen_lightness);
mScreenRotation.setSelection(Settings.getScreenRotation());
mReadingDirection.setSelection(Settings.getReadingDirection());
mScaleMode.setSelection(Settings.getPageScaling());
mStartPosition.setSelection(Settings.getStartPosition());
mKeepScreenOn.setChecked(Settings.getKeepScreenOn());
mShowClock.setChecked(Settings.getShowClock());
代码示例来源:origin: stackoverflow.com
final View view = inflater.inflate(R.layout.tab2, container, false);
button.setOnClickListener(new View.OnClickListener()
Integer selectedOption = spinner.getSelectedItemPosition();
textview.setText(myString);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.planets_array, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter( adapter );
代码示例来源:origin: TeamNewPipe/NewPipe
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
nameEditText = view.findViewById(R.id.file_name);
nameEditText.setText(FilenameUtils.createFilename(getContext(), currentInfo.getName()));
selectedAudioIndex = ListHelper.getDefaultAudioFormat(getContext(), currentInfo.getAudioStreams());
streamsSpinner = view.findViewById(R.id.quality_spinner);
streamsSpinner.setOnItemSelectedListener(this);
threadsCountTextView = view.findViewById(R.id.threads_count);
threadsSeekBar = view.findViewById(R.id.threads);
threadsCountTextView.setText(String.valueOf(threads));
threadsSeekBar.setProgress(threads - 1);
threadsSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
代码示例来源:origin: stackoverflow.com
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main, container, false);
final Spinner spinner = (Spinner) rootView.findViewById(R.id.email_spinner);
// Create an ArrayAdapter using the string array and a default spinner layout
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(),
R.array.email_array, android.R.layout.simple_spinner_item);
// Specify the layout to use when the list of choices appears
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// Apply the adapter to the spinner
spinner.setAdapter(adapter);
Button buttonSubmit = (Button) rootView.findViewById(R.id.NextActivity);
buttonSubmit.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent i = new Intent(getActivity().getApplicationContext(), Second.class);
i.putExtra("SpinnerValue", spinner.getSelectedItem().toString());
getActivity().startActivity(i);
}
});
return rootView;
}
代码示例来源:origin: PrivacyApps/calendar-import-export
private void addReminder(int index) {
View newItem = mActivity.getLayoutInflater().inflate(R.layout.reminder, mItemsHolder, false);
final int id = mNewId++;
newItem.setId(id);
Spinner dropDown = (Spinner) newItem.findViewById(R.id.reminder_item);
dropDown.setSelection(index);
View.OnClickListener delClick = new View.OnClickListener() {
public void onClick(View view) {
mItemsHolder.removeView(mItemsHolder.findViewById(id));
}
};
Button button = (Button) newItem.findViewById(R.id.button_reminder_delete);
button.setOnClickListener(delClick);
mItemsHolder.addView(newItem);
}
代码示例来源:origin: stackoverflow.com
public class FindBeerActivity extends Activity {
// Get the Button variable first
private Button myButton;
private TextView brands;
private Spinner color;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.content_main);
myButton = (Button) findViewById(R.id.my_button);
brands = (TextView) findViewById(R.id.brands);
color = (Spinner) findViewById(R.id.color);
myButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String beerType=String.valueOf(color.getSelectedItem());
brands.setText(beerType);
Toast.makeText(this,"Clicked", Toast.LENGTH_LONG).show();
}
});
}
}
代码示例来源:origin: ankidroid/Anki-Android
TextView tv = new TextView(this);
tv.setText(getText(R.string.multimedia_editor_trans_poweredglosbe));
linearLayout.addView(tv);
mSpinnerFrom = new Spinner(this);
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item,
mLanguageLister.getLanguages());
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mSpinnerFrom.setAdapter(adapter);
linearLayout.addView(mSpinnerFrom);
linearLayout.addView(tvTo);
mSpinnerTo = new Spinner(this);
ArrayAdapter<String> adapterTo = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item,
mLanguageLister.getLanguages());
adapterTo.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mSpinnerTo.setAdapter(adapterTo);
linearLayout.addView(mSpinnerTo);
mSpinnerFrom.setSelection(getSpinnerIndex(mSpinnerFrom, fromLang));
mSpinnerTo.setSelection(getSpinnerIndex(mSpinnerTo, toLang));
String fromLang1 = mSpinnerFrom.getSelectedItem().toString();
String toLang1 = mSpinnerTo.getSelectedItem().toString();
preferences.edit().putString("translatorLastLanguageFrom", fromLang1).apply();
preferences.edit().putString("translatorLastLanguageTo", toLang1).apply();
代码示例来源:origin: syncthing/syncthing-android
mShareTitle.setText(getResources().getQuantityString(R.plurals.file_name_title,
files.size() > 1 ? 2 : 1));
mShareButton.setOnClickListener(view -> {
if (files.size() == 1)
files.entrySet().iterator().next().setValue(mShareName.getText().toString());
Folder folder = (Folder) mFoldersSpinner.getSelectedItem();
File directory = new File(folder.path, getSavedSubDirectory());
CopyFilesTask mCopyFilesTask = new CopyFilesTask(this, files, folder, directory);
});
mFoldersSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
browseButton.setOnClickListener(view -> {
Folder folder = (Folder) mFoldersSpinner.getSelectedItem();
File initialDirectory = new File(folder.path, getSavedSubDirectory());
startActivityForResult(FolderPickerActivity.createIntent(getApplicationContext(),
});
mCancelButton.setOnClickListener(view -> finish());
mSubDirectoryTextView.setText(getSavedSubDirectory());
内容来源于网络,如有侵权,请联系作者删除!