本文整理汇总了Java中android.widget.Spinner.setAdapter方法的典型用法代码示例。如果您正苦于以下问题:Java Spinner.setAdapter方法的具体用法?Java Spinner.setAdapter怎么用?Java Spinner.setAdapter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.Spinner
的用法示例。
在下文中一共展示了Spinner.setAdapter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import android.widget.Spinner; //导入方法依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_pager);
FragmentManager fm = getSupportFragmentManager();
VerticalViewPager verticalPager = (VerticalViewPager) findViewById(R.id.vertical_pager);
VerticalPagerAdapter adapter = new VerticalPagerAdapter(fm);
verticalPager.setAdapter(adapter);
Toolbar toolBar = (Toolbar) findViewById(R.id.tool_bar);
setSupportActionBar(toolBar);
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayShowTitleEnabled(false);
}
sortDropDown = (Spinner) findViewById(R.id.sort_selection);
ArrayAdapter<CharSequence> spinnerAdapter = ArrayAdapter.createFromResource(this,
R.array.sort_functions,
R.layout.spinner_item);
spinnerAdapter.setDropDownViewResource(R.layout.support_simple_spinner_dropdown_item);
sortDropDown.setAdapter(spinnerAdapter);
}
示例2: AndroidSelectElement
import android.widget.Spinner; //导入方法依赖的package包/类
AndroidSelectElement(final Context context, Document document) {
super(context, document, "select", new Spinner(context));
spinner = (Spinner) child;
spinner.setAdapter(new SelectElementAdapter());
/* spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
if (i != 0) throw new RuntimeException("YAY");
spinner.setSelection(i);
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
}); */
}
示例3: onCreate
import android.widget.Spinner; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_employer_create_job);
EditText name = (EditText) findViewById(R.id.jobName);
jobName = name.getText().toString();
//implement question spinner
spinner = (Spinner) findViewById(R.id.questions_spinner);
spinner.setOnItemSelectedListener(this);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.questions_list, 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);
}
示例4: onFinishInflate
import android.widget.Spinner; //导入方法依赖的package包/类
@Override
protected void onFinishInflate() {
super.onFinishInflate();
tvAmountA = (TextView) findViewById(R.id.tvAmountA);
tvAmountB = (TextView) findViewById(R.id.tvAmountB);
sCurrencyA = (Spinner) findViewById(R.id.sCurrencyA);
sCurrencyB = (Spinner) findViewById(R.id.sCurrencyB);
ArrayAdapter<String> btcAdapter = new ArrayAdapter<String>(getContext(),
android.R.layout.simple_spinner_item,
new String[]{"BTC"});
sCurrencyA.setAdapter(btcAdapter);
sCurrencyA.setEnabled(false);
ArrayAdapter<String> xmrAdapter = new ArrayAdapter<String>(getContext(),
android.R.layout.simple_spinner_item,
new String[]{"XMR"});
sCurrencyB.setAdapter(xmrAdapter);
sCurrencyB.setEnabled(false);
}
示例5: setupExpirySpinners
import android.widget.Spinner; //导入方法依赖的package包/类
private void setupExpirySpinners() {
expiryDaySpinner = (Spinner) findViewById(R.id.expiry_day_spinner);
expiryMonthSpinner = (Spinner) findViewById(R.id.expiry_month_spinner);
expiryYearSpinner = (Spinner) findViewById(R.id.expiry_year_spinner);
List<String> days = new ArrayList<>();
for (int i = 0; i < 31; i++) {
days.add("" + (i + 1));
}
// Leave the default view (android.R.layout.simple_spinner_item) but set custom view for dropdown to add extra padding
ArrayAdapter<String> dayAdapter = new ArrayAdapter<>(this,
android.R.layout.simple_spinner_item, days);
dayAdapter.setDropDownViewResource(R.layout.spinner_dropdown);
expiryDaySpinner.setAdapter(dayAdapter);
ArrayAdapter<CharSequence> monthAdapter = ArrayAdapter.createFromResource(this,
R.array.months_array, android.R.layout.simple_spinner_item);
monthAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
expiryMonthSpinner.setAdapter(monthAdapter);
Date dt = new Date();
List<String> years = new ArrayList<>();
for (int i = 0; i <= 10; i++) {
years.add("" + (dt.getYear() + 1900 + i));
}
ArrayAdapter<String> yearAdapter = new ArrayAdapter<>(this,
android.R.layout.simple_spinner_item, years);
yearAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
expiryYearSpinner.setAdapter(yearAdapter);
}
示例6: fillSelectablePresets
import android.widget.Spinner; //导入方法依赖的package包/类
public void fillSelectablePresets(final View dlgView, List<TGTremoloBarPreset> presets, TGTremoloBarPreset selection) {
ArrayAdapter<TGSelectableItem> adapter = new ArrayAdapter<TGSelectableItem>(getActivity(), android.R.layout.simple_spinner_item, createSelectablePresets(presets));
final Spinner spinner = (Spinner) dlgView.findViewById(R.id.tremolo_bar_dlg_preset_value);
spinner.setAdapter(adapter);
this.updateSelectedPreset(spinner, selection);
this.appendListeners(dlgView, spinner);
}
示例7: onCreate
import android.widget.Spinner; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_unicode);
// initialize renderer
renderer = MongolCode.INSTANCE;
// text views
tvLabel = (TextView) findViewById(R.id.tvTitle);
tvResults = (TextView) findViewById(R.id.tvUnicodeResults);
// set Mongol font
Typeface tf = MongolFont.get(MongolFont.QAGAN, this);
//Typeface tf = Typeface.createFromAsset(this.getAssets(), "fonts/MQG8F02.ttf");
//Typeface tf = Typeface.createFromAsset(this.getAssets(), "fonts/MenksoftHawang.ttf");
tvResults.setTypeface(tf);
// Chagaan tologai spinner
List<String> viewChoices = new ArrayList<>(Arrays.asList(names));
viewChoices.add("MVS");
viewChoices.add("NNBS");
viewChoices.add("Other");
Spinner chagaanTologaiSpinner = (Spinner) findViewById(R.id.spinnerChagaanTolgai);
ArrayAdapter<String> adapterChagaanTologai = new ArrayAdapter<>(this,
android.R.layout.simple_spinner_item, viewChoices);
adapterChagaanTologai.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
chagaanTologaiSpinner.setAdapter(adapterChagaanTologai);
chagaanTologaiSpinner.setOnItemSelectedListener(this);
// Font spinner
List<String> fontChoices = new ArrayList<>(Arrays.asList(fonts));
Spinner fontSpinner = (Spinner) findViewById(R.id.spinnerFont);
ArrayAdapter<String> adapterFont = new ArrayAdapter<>(this,
android.R.layout.simple_spinner_item, fontChoices);
adapterFont.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
fontSpinner.setAdapter(adapterFont);
fontSpinner.setOnItemSelectedListener(this);
}
示例8: populateSpinner
import android.widget.Spinner; //导入方法依赖的package包/类
protected void populateSpinner() {
ArrayAdapter<String> adapter = new ArrayAdapter<String>(
this, android.R.layout.simple_spinner_item, categories);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
Spinner sItems = (Spinner) findViewById(R.id.catSpinner);
sItems.setAdapter(adapter);
}
示例9: setControls
import android.widget.Spinner; //导入方法依赖的package包/类
private void setControls() {
iconNumber = (Spinner) findViewById(R.id.stIconNumber);
List<String> spinnerArray = new ArrayList<>();
spinnerArray.add(String.valueOf(Const.ICONS_SIZE.ICONS_BIG));
spinnerArray.add(String.valueOf(Const.ICONS_SIZE.ICONS_MEDIUM));
spinnerArray.add(String.valueOf(Const.ICONS_SIZE.ICONS_LOW));
spinnerArray.add(String.valueOf(Const.ICONS_SIZE.ICONS_LOWER));
spinnerArray.add(String.valueOf(Const.ICONS_SIZE.ICONS_LOWEST));
spinnerArray.add(String.valueOf(Const.ICONS_SIZE.ICONS_LOWESTER));
spinnerArray.add(String.valueOf(Const.ICONS_SIZE.ICONS_LOWESTEREST));
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
R.layout.spinner_item, spinnerArray);
iconNumber.setAdapter(adapter);
iconNumber.getBackground().setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.SRC_ATOP);
iconNumber.setSelection(selectedPosition, true);
btnChooseWallpaper = (Button) findViewById(R.id.stWallpaperButton);
btnChooseWallpaper.setOnClickListener(this);
btnWallpaperDefault = (Button) findViewById(R.id.stWallpaperButtonDefault);
btnWallpaperDefault.setOnClickListener(this);
txtCustomTitle = (EditText) findViewById(R.id.stCustomTitleValue);
}
示例10: onCreate
import android.widget.Spinner; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_camera_capture);
File outputFile = new File(getFilesDir(), "camera-test.mp4");
TextView fileText = (TextView) findViewById(R.id.cameraOutputFile_text);
fileText.setText(outputFile.toString());
Spinner spinner = (Spinner) findViewById(R.id.cameraFilter_spinner);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
R.array.cameraFilterNames, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// Apply the adapter to the spinner.
spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(this);
// Define a handler that receives camera-control messages from other threads. All calls
// to Camera must be made on the same thread. Note we create this before the renderer
// thread, so we know the fully-constructed object will be visible.
mCameraHandler = new CameraHandler(this);
mRecordingEnabled = sVideoEncoder.isRecording();
// Configure the GLSurfaceView. This will start the Renderer thread, with an
// appropriate EGL context.
mGLView = (GLSurfaceView) findViewById(R.id.cameraPreview_surfaceView);
mGLView.setEGLContextClientVersion(2); // select GLES 2.0
mRenderer = new CameraSurfaceRenderer(mCameraHandler, sVideoEncoder, outputFile);
mGLView.setRenderer(mRenderer);
mGLView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
Log.d(TAG, "onCreate complete: " + this);
}
示例11: initOutlineSizeSpinner
import android.widget.Spinner; //导入方法依赖的package包/类
private void initOutlineSizeSpinner(float outlineSize) {
Spinner spinner = (Spinner) findViewById(R.id.edit_outline_size);
spinner.setOnItemSelectedListener(this);
String[] sizeList = new String[]{"Thin", "Normal", "Thick"};
spinner.setAdapter(new ArrayAdapter<>(this,
android.R.layout.simple_spinner_dropdown_item, sizeList));
spinner.setSelection(outlineSizeToPosition(outlineSize));
}
示例12: onViewCreated
import android.widget.Spinner; //导入方法依赖的package包/类
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
final Spinner spinnerTimer = (Spinner) view.findViewById(R.id.fragment_components_menus_spinner_timer);
final Spinner spinnerWhen = (Spinner) view.findViewById(R.id.fragment_components_menus_spinner_when);
final Spinner spinnerColors = (Spinner) view.findViewById(R.id.fragment_components_menus_spinner_colors);
final SpinnerLayout spinnerLayoutTimer = (SpinnerLayout) view.findViewById(R.id.fragment_components_menus_spinner_layout_timer);
final SpinnerLayout sSpinnerLayoutWhen = (SpinnerLayout) view.findViewById(R.id.fragment_components_menus_spinner_layout_when);
final SpinnerLayout spinnerLayoutColors = (SpinnerLayout) view.findViewById(R.id.fragment_components_menus_spinner_layout_colors);
final SpinnerLayout spinnerLayoutColorsDisabled = (SpinnerLayout) view.findViewById(R.id.fragment_components_menus_spinner_layout_colors_disabled);
final Context context = getActivity();
spinnerTimer.setAdapter(new TimerAdapter(context));
spinnerTimer.setSelection(2, false);
spinnerTimer.setOnItemSelectedListener(this);
spinnerWhen.setAdapter(new ArrayAdapter<>(context, android.R.layout.simple_list_item_1, WHEN));
spinnerWhen.setSelection(0, false);
spinnerWhen.setOnItemSelectedListener(this);
spinnerColors.setAdapter(new ArrayAdapter<>(context, android.R.layout.simple_list_item_1, COLORS));
spinnerColors.setSelection(0, false);
spinnerColors.setOnItemSelectedListener(this);
spinnerLayoutTimer.setAdapter(new TimerAdapter(context));
spinnerLayoutTimer.setSelection(2, false);
spinnerLayoutTimer.setOnItemSelectedListener(this);
sSpinnerLayoutWhen.setAdapter(new ArrayAdapter<>(context, android.R.layout.simple_list_item_1, WHEN));
sSpinnerLayoutWhen.setOnItemSelectedListener(this);
spinnerLayoutColors.setAdapter(new ArrayAdapter<>(context, android.R.layout.simple_list_item_1, COLORS));
spinnerLayoutColors.setOnItemSelectedListener(this);
spinnerLayoutColorsDisabled.setAdapter(new ArrayAdapter<>(context, android.R.layout.simple_list_item_1, COLORS));
}
示例13: onActivityCreated
import android.widget.Spinner; //导入方法依赖的package包/类
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
if (!AuthToken.FIsValid()) {
MFBUtil.Alert(this, getString(R.string.errCannotAddAircraft), getString(R.string.errMustBeSignedInToCreateAircraft));
Cancel();
return;
}
// Give the aircraft a tailnumber based on locale
m_ac.TailNumber = CountryCode.BestGuessForCurrentLocale().Prefix;
findViewById(R.id.btnMakeModel).setOnClickListener(this);
findViewById(R.id.ckAnonymous).setOnClickListener(this);
String[] rgszInstanceTypes = new String[Aircraft.rgidInstanceTypes.length];
for (int i = 0; i < Aircraft.rgidInstanceTypes.length; i++)
rgszInstanceTypes[i] = getString(Aircraft.rgidInstanceTypes[i]);
Spinner sp = (Spinner) findViewById(R.id.spnAircraftType);
ArrayAdapter<String> adapter = new ArrayAdapter<>(getActivity(), R.layout.mfbsimpletextitem, rgszInstanceTypes);
sp.setAdapter(adapter);
sp.setSelection(0);
sp.setOnItemSelectedListener(this);
// make the hint for creating make/model a hyperlink
TextView txtHint = (TextView) findViewById(R.id.txtAddMakesHint);
txtHint.setText(getString(R.string.lblAddMakes));
txtHint.setMovementMethod(LinkMovementMethod.getInstance());
// Get available makes/models, but only if we have none. Can refresh.
// This avoids getting makes/models when just getting a picture.
if (AvailableMakesAndModels == null || AvailableMakesAndModels.length == 0) {
GetMakesTask gt = new GetMakesTask(this.getActivity());
gt.execute();
}
toView();
}
示例14: initFontFamilySpinner
import android.widget.Spinner; //导入方法依赖的package包/类
private void initFontFamilySpinner(String familyName) {
Spinner spinner = (Spinner) findViewById(R.id.edit_font_family);
spinner.setOnItemSelectedListener(this);
mFontFamilySet = new FontFamilySet();
mSelectedFontFamily = mFontFamilySet.getFontFamily(familyName);
mFontFamilyNameList = mFontFamilySet.getFontFamilyDisplayNameList();
spinner.setAdapter(new ArrayAdapter<>(this,
android.R.layout.simple_spinner_dropdown_item, mFontFamilyNameList));
spinner.setSelection(mFontFamilyNameList.indexOf(mSelectedFontFamily.displayName));
}
示例15: updateSpinner
import android.widget.Spinner; //导入方法依赖的package包/类
private void updateSpinner() {
final ArrayList<LocaleRenderer> localesList = mContents.getLocalesList(getActivity());
final Spinner localeSpinner =
(Spinner)mRootView.findViewById(R.id.user_dictionary_add_locale);
final ArrayAdapter<LocaleRenderer> adapter = new ArrayAdapter<>(
getActivity(), android.R.layout.simple_spinner_item, localesList);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
localeSpinner.setAdapter(adapter);
localeSpinner.setOnItemSelectedListener(this);
}