本文整理汇总了Java中android.widget.Spinner.setOnItemSelectedListener方法的典型用法代码示例。如果您正苦于以下问题:Java Spinner.setOnItemSelectedListener方法的具体用法?Java Spinner.setOnItemSelectedListener怎么用?Java Spinner.setOnItemSelectedListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.Spinner
的用法示例。
在下文中一共展示了Spinner.setOnItemSelectedListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import android.widget.Spinner; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mRadiogroup = (RadioGroup) findViewById(R.id.radiogroup);
mImageView = (ImageView) findViewById(R.id.image);
mImageView.setOnClickListener(this);
Spinner startScaleTypeSpinner = (Spinner) findViewById(R.id.spinner_start_scaletype);
Spinner endScaleTypeSpinner = (Spinner) findViewById(R.id.spinner_end_scaletype);
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, mScaleTypes);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
startScaleTypeSpinner.setAdapter(adapter);
endScaleTypeSpinner.setAdapter(adapter);
startScaleTypeSpinner.setOnItemSelectedListener(this);
endScaleTypeSpinner.setOnItemSelectedListener(this);
}
示例2: onCreate
import android.widget.Spinner; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_play_movie_surface);
mSurfaceView = (SurfaceView) findViewById(R.id.playMovie_surface);
mSurfaceView.getHolder().addCallback(this);
// Populate file-selection spinner.
Spinner spinner = (Spinner) findViewById(R.id.playMovieFile_spinner);
// Need to create one of these fancy ArrayAdapter thingies, and specify the generic layout
// for the widget itself.
mMovieFiles = MiscUtils.getFiles(getFilesDir(), "*.mp4");
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, mMovieFiles);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// Apply the adapter to the spinner.
spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(this);
updateControls();
}
示例3: onCreate
import android.widget.Spinner; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_banner_style);
banner = (Banner) findViewById(R.id.banner);
spinnerStyle = (Spinner) findViewById(R.id.spinnerStyle);
spinnerStyle.setOnItemSelectedListener(this);
//默认是CIRCLE_INDICATOR
banner.setImages(App.images)
.setBannerTitles(App.titles)
.setBannerStyle(BannerConfig.NOT_INDICATOR)
.setImageLoader(new GlideImageLoader())
.start();
}
示例4: setupSpinner
import android.widget.Spinner; //导入方法依赖的package包/类
private void setupSpinner() {
Spinner spinner = findViewById(R.id.spinner);
spinner.setOnItemSelectedListener(mMainItemSelected);
List<String> categories = new ArrayList<>();
categories.add("All");
categories.add("Photos");
categories.add("Videos");
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, categories);
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(dataAdapter);
Spinner spinnerFilter = findViewById(R.id.spinnerFilter);
spinnerFilter.setOnItemSelectedListener(mFilterItemSelected);
List<String> filter = new ArrayList<>();
filter.add("CLUSTER BY ALBUM");
filter.add("CLUSTER BY TIME");
filter.add("CLUSTER BY LOCATION");
filter.add("CLUSTER BY TAG");
filter.add("CLUSTER BY SIZE");
filter.add("CLUSTER BY FACE");
ArrayAdapter<String> dataAdapterFilter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, filter);
dataAdapterFilter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerFilter.setAdapter(dataAdapterFilter);
}
示例5: 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);
}
示例6: 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);
}
示例7: SubtitleDelayPickerDialog
import android.widget.Spinner; //导入方法依赖的package包/类
public SubtitleDelayPickerDialog(Context context, OnDelayChangeListener callBack, int delay, int ratio, boolean hasRatio) {
super(context);
getWindow().setGravity(Gravity.TOP);
getWindow().setBackgroundDrawable(new ColorDrawable(VideoInfoCommonClass.getAlphaColor(ContextCompat.getColor(context, R.color.background_material_dark),128)));
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
mContext = context;
mCallBack = callBack;
setIcon(R.drawable.ic_menu_delay);
LayoutInflater inflater =
(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.subtitle_delay_picker_dialog, null);
setView(view);
mSubtitleDelayPicker = (SubtitleDelayPickerAbstract) view.findViewById(R.id.subtitleDelayPicker);
mSubtitleDelayPicker.init(delay, this);
// Setup Spinner
Spinner sp = (Spinner) view.findViewById(R.id.subtitle_delay_ratio_spinner);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
mContext, R.array.subtitle_delay_ratio_array, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
sp.setAdapter(adapter);
sp.setSelection(ratio);
sp.setOnItemSelectedListener(this);
updateTitle(delay);
setCancelable(true);
setCanceledOnTouchOutside(true);
}
示例8: 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);
}
示例9: initViewsDialogEdit
import android.widget.Spinner; //导入方法依赖的package包/类
void initViewsDialogEdit(View v, final Server server, final int serverListPosition) {
pairingInfoTextView.setVisibility(View.GONE);
final ServerDatabaseHandler dbHandler = ServerDatabaseHandler.getInstance(getActivity());
certificateSpinner = (Spinner) v.findViewById(R.id.certificateSpinner);
List<CertificateSpinnerItem> spinnerList = dbHandler.getSpinnerList();
ArrayAdapter<CertificateSpinnerItem> spinnerArrayAdapter = new ArrayAdapter<>(
getActivity().getApplicationContext(),
R.layout.dialog_certificate_spinner_textview,
spinnerList);
spinnerArrayAdapter.setDropDownViewResource(R.layout.dialog_certificate_spinner_dropdown_textview);
certificateSpinner.setAdapter(spinnerArrayAdapter);
certificateSpinner.getBackground().setColorFilter(getResources().getColor(R.color.colorAccent), PorterDuff.Mode.SRC_ATOP);
certificateSpinner.setOnTouchListener(this);
certificateSpinner.setOnItemSelectedListener(this);
for (int i = 0; i < spinnerList.size(); i++){
if (((CertificateIdAndFingerprint) spinnerList.get(i)).getId() == server.getCertificateId()){
certificateSpinner.setSelection(i);
}
}
v.findViewById(R.id.deleteServerBtn).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dbHandler.deleteServer(server.getId());
serverAdapterListCallbacks.deleteServer(serverListPosition);
cancel();
}
});
dbHandler.close();
}
示例10: 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));
}
示例11: onCreate
import android.widget.Spinner; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
// Retrieve the widget id provided by the intent
mAppWidgetId = getIntent().getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1);
// Set the Activity result to RESULT_CANCELED immediately : thus the App Widget host will always be notified
// in case of error or if the user cancels the configuration and the App Widget will not be added
notifyResult(RESULT_CANCELED);
if (mAppWidgetId == -1) {
// Error, no id provided
finish();
}
setContentView(R.layout.widget_configuration);
// Content spinner setup
Spinner contentSpinner = (Spinner)findViewById(R.id.content_spinner);
ArrayAdapter<CharSequence> contentAdapter = ArrayAdapter.createFromResource(this, R.array.video_content_array, android.R.layout.simple_spinner_item);
contentAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
contentSpinner.setAdapter(contentAdapter);
contentSpinner.setOnItemSelectedListener(new OnContentItemSelectedListener());
mValidateButton = (Button)findViewById(R.id.validate_button);
mValidateButton.setOnClickListener(mValidateButtonClickListener);
}
示例12: TimeSpanPicker
import android.widget.Spinner; //导入方法依赖的package包/类
public TimeSpanPicker(Context context, AttributeSet attrs, int defStyle)
{
super(context, attrs, defStyle);
this.context = context;
final LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
dialog = inflater.inflate(R.layout.time_span_dialog, this, true);
timeSpan = new TimeSpan(-1);
timeSpanEditText = (EditText) dialog.findViewById(R.id.timeSpanEditText);
timeSpanEditText.setText("0");
timeSpanSpinner = (Spinner) dialog.findViewById(R.id.timeSpanSpinner);
timeSpanDisableCheckbox = (CheckBox) dialog.findViewById(R.id.timeSpanDisableCheckBox);
timeSpanDisableCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
{
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b)
{
timeSpanEditText.setEnabled(!b);
timeSpanSpinner.setEnabled(!b);
}
});
adapter = ArrayAdapter.createFromResource(context, R.array.shareExpirationNames, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
timeSpanSpinner.setAdapter(adapter);
timeSpanSpinner.setOnItemSelectedListener(this);
}
示例13: onCreate
import android.widget.Spinner; //导入方法依赖的package包/类
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_weather_qbyid);
spProvince = (Spinner) findViewById(R.id.spProvince);
spProvince.setOnItemSelectedListener(this);
spCity = (Spinner) findViewById(R.id.spCity);
spCity.setOnItemSelectedListener(this);
spDistrict = (Spinner) findViewById(R.id.spDistrict);
spDistrict.setOnItemSelectedListener(this);
// 获取API实例,请求支持预报的城市列表
Weather api = (Weather) MobAPI.getAPI(Weather.NAME);
api.getSupportedCities(this);
}
示例14: onCreate
import android.widget.Spinner; //导入方法依赖的package包/类
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_custom_semi_automatic);
spAPI = (Spinner) findViewById(R.id.spAPI);
spAPI.setOnItemSelectedListener(this);
spPath = (Spinner) findViewById(R.id.spPath);
spPath.setOnItemSelectedListener(this);
llParams = (LinearLayout) findViewById(R.id.llParams);
findViewById(R.id.btnSearch).setOnClickListener(this);
tvJson = (TextView) findViewById(R.id.tvJson);
getAPIList();
}
示例15: 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));
}