Java 类android.widget.AdapterView.OnItemSelectedListener 实例源码
项目:tuxguitar
文件:TGBrowserView.java
@SuppressWarnings("unchecked")
public void refreshCollections() {
ArrayAdapter<TGSelectableItem> arrayAdapter = new ArrayAdapter<TGSelectableItem>(findActivity(), R.layout.view_browser_spinner_item, createCollectionValues());
arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
TGSelectableItem selectedItem = new TGSelectableItem(findCurrentCollection(), null);
Integer selectedItemPosition = arrayAdapter.getPosition(selectedItem);
Spinner spinner = (Spinner) this.findViewById(R.id.browser_collections);
OnItemSelectedListener listener = spinner.getOnItemSelectedListener();
spinner.setOnItemSelectedListener(null);
if(!this.isSameCollection(arrayAdapter, (ArrayAdapter<TGSelectableItem>) spinner.getAdapter())) {
spinner.setAdapter(arrayAdapter);
}
if( spinner.getSelectedItemPosition() != selectedItemPosition ) {
spinner.setSelection(selectedItemPosition, false);
}
spinner.setOnItemSelectedListener(listener);
}
项目:financisto1-holo
文件:DateFilterActivity.java
private void createPeriodsSpinner() {
spinnerPeriodType = (Spinner) findViewById(R.id.period);
spinnerPeriodType.setAdapter(createSpinnerAdapter(this, periods));
spinnerPeriodType.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
PeriodType period = periods[position];
if (period == PeriodType.CUSTOM) {
selectCustom();
} else {
selectPeriod(period);
}
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
}
});
}
项目:TuxGuitar-1.3.1-fork
文件:TGBrowserView.java
@SuppressWarnings("unchecked")
public void refreshCollections() {
ArrayAdapter<TGSelectableItem> arrayAdapter = new ArrayAdapter<TGSelectableItem>(findActivity(), R.layout.view_browser_spinner_item, createCollectionValues());
arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
TGSelectableItem selectedItem = new TGSelectableItem(findCurrentCollection(), null);
Integer selectedItemPosition = arrayAdapter.getPosition(selectedItem);
Spinner spinner = (Spinner) this.findViewById(R.id.browser_collections);
OnItemSelectedListener listener = spinner.getOnItemSelectedListener();
spinner.setOnItemSelectedListener(null);
if(!this.isSameCollection(arrayAdapter, (ArrayAdapter<TGSelectableItem>) spinner.getAdapter())) {
spinner.setAdapter(arrayAdapter);
}
if( spinner.getSelectedItemPosition() != selectedItemPosition ) {
spinner.setSelection(selectedItemPosition, false);
}
spinner.setOnItemSelectedListener(listener);
}
项目:flowzr-android-black
文件:DateFilterActivity.java
private void createPeriodsSpinner() {
spinnerPeriodType = (Spinner) findViewById(R.id.period);
spinnerPeriodType.setAdapter(createSpinnerAdapter(this, periods));
spinnerPeriodType.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
if (position<0) {
position=0;
}
PeriodType period = periods[position];
if (period == PeriodType.CUSTOM) {
selectCustom();
} else {
selectPeriod(period);
}
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
}
});
}
项目:flowzr-android-black
文件:DateFilterFragment.java
private void createPeriodsSpinner() {
spinnerPeriodType = (Spinner) getView().findViewById(R.id.period);
spinnerPeriodType.setAdapter(createSpinnerAdapter(getContext(), periods));
spinnerPeriodType.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
if (position>0) {
PeriodType period = periods[position];
if (period == PeriodType.CUSTOM) {
selectCustom();
} else {
selectPeriod(period);
}
}
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
}
});
}
项目:PdDroidPublisher
文件:MidiConfigDialog.java
protected void refreshInputList() {
OnItemSelectedListener listener = midiInSpinner.getOnItemSelectedListener();
midiInSpinner.setOnItemSelectedListener(null);
midiInArrayList.clear();
midiInArrayList.add(new MidiPortAdapter());
int position = 0;
for (MidiDevice midiDevice : midiManager.getDeveices()) {
for (MidiInput midiInput : midiDevice.getInputs()) {
if (midiInput == midiManager.getInput()) {
position = midiInArrayList.getCount();
}
midiInArrayList.add(new MidiPortAdapter(midiDevice, midiInput));
}
}
midiInSpinner.setSelection(position);
midiInSpinner.setOnItemSelectedListener(listener);
}
项目:WikiCards
文件:MainActivity.java
private void initCategorySpinner() {
categoryAdapter = new CategoryListAdapter(this);
categorySpinner = (Spinner) this.findViewById(R.id.spinner_category);
categorySpinner.setAdapter(categoryAdapter);
categorySpinner.setSelection(readSelectedCategory() - 1);
categorySpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int idx,
long id) {
switchSelectedCategory((int) id);
storage = new WordsStorage(MainActivity.this, (int) id);
langAdapter.notifyDataSetChanged();
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// Do nothing in this case.
}
});
}
项目:twitterwidget
文件:TimeLineFragmentConfig.java
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
applyButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
onApplyButtonClick();
}
});
tweetListSpinner
.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent,
View view, int position, long id) {
onSpinnerItemSelected(position);
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
}
});
}
项目:YiBo
文件:AddAccountActivity.java
private void bindEvent() {
Button btnBack = (Button) this.findViewById(R.id.btnBack);
btnBack.setOnClickListener(new GoBackClickListener(R.anim.slide_in_right));
spServiceProvider.setAdapter(new ServiceProviderSpinnerAdapter(this));
OnItemSelectedListener spItemListener = new AddAccountSpItemSelectedListener(this);
spServiceProvider.setOnItemSelectedListener(spItemListener);
spConfigApp.setAdapter(new ConfigAppSpinnerAdapter(this));
OnItemSelectedListener configAppItemSelectedListener = null;
configAppItemSelectedListener = new AddAccountConfigAppItemSelectedListener(this);
spConfigApp.setOnItemSelectedListener(configAppItemSelectedListener);
TextWatcher editTextWatcher = new AddAccountTextWatcher(this);
etUsername.addTextChangedListener(editTextWatcher);
etPassword.addTextChangedListener(editTextWatcher);
etRestProxy.addTextChangedListener(editTextWatcher);
etSearchProxy.addTextChangedListener(editTextWatcher);
AddAccountAuthorizeClickListener authorizeClickListener = null;
authorizeClickListener = new AddAccountAuthorizeClickListener(this);
btnAuthorize.setOnClickListener(authorizeClickListener);
}
项目:encdroidMC
文件:ConfigSyncActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_config_sync);
volumeName = (EditText) findViewById(R.id.volumeName);
//volumeName.setFocusable(false);
volumePath = (EditText) findViewById(R.id.volumePath);
//volumePath.setFocusable(false);
password = (EditText) findViewById(R.id.volumePassword);
password.setTransformationMethod(PasswordTransformationMethod.getInstance());
password.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
onlyWifiCheckBox = ((CheckBox) findViewById(R.id.onlyWifi));
removeAfterCheckBox = ((CheckBox) findViewById(R.id.removeAfter));
localFolder = ((EditText) findViewById(R.id.localFolder));
syncID = ((EditText) findViewById(R.id.syncID));
syncID.setFocusable(false);
spin1=(Spinner) findViewById(R.id.selectedRule);
ArrayAdapter<String> adapter=new ArrayAdapter<String>(ConfigSyncActivity.this, android.R.layout.simple_spinner_item, rules);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spin1.setAdapter(adapter);
spin1.setOnTouchListener(this);
spin1.setOnItemSelectedListener((OnItemSelectedListener) this);
refresh(null);
}
项目:lr_dialer
文件:AbstractAQuery.java
/**
* Register a callback method for when an item is selected.
*
* @param listener The item selected listener.
* @return self
*/
public T itemSelected(OnItemSelectedListener listener)
{
if (view instanceof AdapterView)
{
AdapterView<?> alv = (AdapterView<?>) view;
alv.setOnItemSelectedListener(listener);
}
return self();
}
项目:ExoPlayerDemo
文件:AbstractAQuery.java
/**
* Register a callback method for when an item is selected.
*
* @param listener The item selected listener.
* @return self
*/
public T itemSelected(OnItemSelectedListener listener){
if(view instanceof AdapterView){
AdapterView<?> alv = (AdapterView<?>) view;
alv.setOnItemSelectedListener(listener);
}
return self();
}
项目:DroidShows
文件:DroidShows.java
@SuppressLint("NewApi")
private void arrangeActionBar(Menu menu) {
menu.findItem(TOGGLE_ARCHIVE_MENU_ITEM).setVisible(false);
menu.findItem(LOG_MODE_ITEM).setVisible(false);
menu.findItem(SEARCH_MENU_ITEM).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
spinner = new Spinner(this);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
spinner.setPopupBackgroundResource(R.drawable.menu_dropdown_panel);
spinner.setAdapter(new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1,
new String[] {
getString(R.string.layout_app_name),
getString(R.string.archive),
getString(R.string.menu_log),
}));
spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View v, int position, long id) {
logMode = position == 2;
showArchive = (position == 2 ? showArchive : position);
if (logMode)
clearFilter(null);
getSeries();
}
public void onNothingSelected(AdapterView<?> arg0) {
}
});
ActionBar actionBar = getActionBar();
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME);
actionBar.setCustomView(spinner);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
actionBar.setIcon(R.drawable.actionbar);
}
项目:Fabric-Example-App-Android
文件:MoPubAdAdapterTest.java
@Test
public void setOnItemSelectedListener_withAdPosition_shouldNotCallListener() {
subject.setOnItemSelectedListener(mockListView, mockOnItemSelectedListener);
ArgumentCaptor<OnItemSelectedListener> listenerCaptor =
ArgumentCaptor.forClass(OnItemSelectedListener.class);
verify(mockListView).setOnItemSelectedListener(listenerCaptor.capture());
OnItemSelectedListener listener = listenerCaptor.getValue();
listener.onItemSelected(mockListView, mockItemView, AD_POSITION, 0);
verify(mockOnItemSelectedListener, never()).onItemSelected(
any(AdapterView.class), any(View.class), anyInt(), anyInt());
}
项目:Fabric-Example-App-Android
文件:MoPubAdAdapterTest.java
@Test
public void setOnItemSelectedListener_withNonAdPosition_shouldCallListener() {
subject.setOnItemSelectedListener(mockListView, mockOnItemSelectedListener);
ArgumentCaptor<OnItemSelectedListener> listenerCaptor =
ArgumentCaptor.forClass(OnItemSelectedListener.class);
verify(mockListView).setOnItemSelectedListener(listenerCaptor.capture());
OnItemSelectedListener listener = listenerCaptor.getValue();
listener.onItemSelected(mockListView, mockItemView, AD_POSITION + 1, 0);
verify(mockOnItemSelectedListener).onItemSelected(
mockListView, mockItemView, AD_POSITION, 0);
}
项目:palette
文件:ViewHelper.java
/**
* Register a callback method for when an item is selected.
*
* @param listener The item selected listener.
* @return self
*/
public ViewHelper itemSelected(OnItemSelectedListener listener) {
if (mView instanceof AdapterView) {
AdapterView<?> alv = (AdapterView<?>) mView;
alv.setOnItemSelectedListener(listener);
}
return this;
}
项目:SyncFrameworkAndroid
文件:SpinnerHelper.java
public SpinnerHelper(Spinner spinner, int loaderID, ResourceCursorAdapter adapter, @LayoutRes int dropDownLayout, OnItemSelectedListener onSelected) {
Spinner = spinner;
mLoaderID = loaderID;
Spinner.setOnItemSelectedListener(onSelected);
Spinner.setAdapter(adapter);
adapter.setDropDownViewResource(dropDownLayout);
}
项目:CardUI
文件:GridActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Intialize and set the Action Bar to Holo Blue
ActionBar actionBar = getActionBar();
actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#33b5e5" )));
GridView grid = (GridView) findViewById(R.id.myGrid);
rowItems = new ArrayList<RowItem>();
String[] titles = {"Movie1","Movie2","Movie3","Movie4","Movie5","Movie6","Movie7","Movie8"};
String[] descriptions = {"First Movie","Second movie","Third Movie","Fourth Movie","Fifth Movie",
"Sixth Movie","Seventh Movie","Eighth Movie"};
//Populate the List
for (int i = 0; i < titles.length; i++) {
RowItem item = new RowItem(images[i], titles[i], descriptions[i]);
rowItems.add(item);
}
// Set the adapter on the ListView
LazyAdapter adapter = new LazyAdapter(getApplicationContext(), R.layout.grid_row, rowItems);
grid.setAdapter(adapter);
grid.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
}
});
}
项目:Wabbit-Messenger---android-client
文件:ItemManaged.java
void setOnItemSelectedListener(OnItemSelectedListener l) {
if (mInstallingManager) {
return;
}
mOnItemSelectedListener = l;
}
项目:Wabbit-Messenger---android-client
文件:ItemManager.java
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
if (mScrollState != OnScrollListener.SCROLL_STATE_IDLE) {
mScrollState = OnScrollListener.SCROLL_STATE_IDLE;
postUpdateItems();
}
final OnItemSelectedListener l = mManaged.getOnItemSelectedListener();
if (l != null) {
l.onItemSelected(adapterView, view, position, id);
}
}
项目:Wabbit-Messenger---android-client
文件:ItemManager.java
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
final OnItemSelectedListener l = mManaged.getOnItemSelectedListener();
if (l != null) {
l.onNothingSelected(adapterView);
}
}
项目:EasyQuranMemorizer
文件:MyMediaPlayer.java
private void initializeReciterSpinner()
{
ReciterDataManger manager = new ReciterDataManger(
getApplicationContext());
downloadedReciterList = manager.getDownloadedReciterList(surah);
// setting reciter spinner list
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, downloadedReciterList);
dataAdapter
.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
reciterSpinner.setAdapter(dataAdapter);
reciterSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view,
int position, long id) {
selectedAuthorName = downloadedReciterList.get(position);
// if (selectedAuthorName != CONSTANT.AUDIO_NOT_FOUND) {
// resetVerse();
// play();
// }
resetVerse();
play();
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
}
});
}
项目:NeXT_pyp
文件:AbstractAQuery.java
/**
* Register a callback method for when an item is selected.
*
* @param listener The item selected listener.
* @return self
*/
public T itemSelected(OnItemSelectedListener listener){
if(view instanceof AdapterView){
AdapterView<?> alv = (AdapterView<?>) view;
alv.setOnItemSelectedListener(listener);
}
return self();
}
项目:NeXT_pyp
文件:AbstractAQuery.java
/**
* Register a callback method for when an item is selected.
*
* @param listener
* The item selected listener.
* @return self
*/
public T itemSelected(OnItemSelectedListener listener) {
if (view instanceof AdapterView) {
AdapterView<?> alv = (AdapterView<?>) view;
alv.setOnItemSelectedListener(listener);
}
return self();
}
项目:NeXT_pyp
文件:AbstractAQuery.java
/**
* Register a callback method for when an item is selected.
*
* @param listener
* The item selected listener.
* @return self
*/
public T itemSelected(OnItemSelectedListener listener) {
if (view instanceof AdapterView) {
AdapterView<?> alv = (AdapterView<?>) view;
alv.setOnItemSelectedListener(listener);
}
return self();
}
项目:Android-Project-Manager
文件:SpinnerUtil.java
public static ArrayAdapter<CharSequence> setCustomSpinnerAdapter (final Context context, final Fragment fragment,
final FragmentManager fragmentManager, String spinnerFileName, Spinner spinner, boolean sort) {
FileOperations fO = new FileOperations(context);
String spinnerItems = fO.readFile(spinnerFileName);
ArrayList<String> spinnerItemsArray = fO.convertToStringList(spinnerItems);
if(sort)
Collections.sort(spinnerItemsArray.subList(0, spinnerItemsArray.size()));
spinnerItemsArray.add("Custom...");
//Set the adapter for the status spinner
final ArrayAdapter<CharSequence> spinnerAdapter = new ArrayAdapter<CharSequence>(context, android.R.layout.simple_spinner_item);
spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerAdapter.addAll(spinnerItemsArray);
spinner.setAdapter(spinnerAdapter);
spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
if( "Custom...".equals((String) spinnerAdapter.getItem(position))) {
DialogFragment customStatusDialog = new CustomStatus();
customStatusDialog.setTargetFragment(fragment, 0);
customStatusDialog.show(fragmentManager, "Custom Status Dialog");
}
}
@Override
public void onNothingSelected(AdapterView<?> arg0) { }
});
return spinnerAdapter;
}
项目:CardUI
文件:GridActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Intialize and set the Action Bar to Holo Blue
ActionBar actionBar = getActionBar();
actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#33b5e5" )));
GridView grid = (GridView) findViewById(R.id.myGrid);
rowItems = new ArrayList<RowItem>();
String[] titles = {"Movie1","Movie2","Movie3","Movie4","Movie5","Movie6","Movie7","Movie8"};
String[] descriptions = {"First Movie","Second movie","Third Movie","Fourth Movie","Fifth Movie",
"Sixth Movie","Seventh Movie","Eighth Movie"};
//Populate the List
for (int i = 0; i < titles.length; i++) {
RowItem item = new RowItem(images[i], titles[i], descriptions[i]);
rowItems.add(item);
}
// Set the adapter on the ListView
LazyAdapter adapter = new LazyAdapter(getApplicationContext(), R.layout.grid_row, rowItems);
grid.setAdapter(adapter);
grid.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
}
});
}
项目:jukefox
文件:SearchActivity.java
private void registerSpinner(int selectedPos) {
searchInSelectionSpinner = (Spinner)findViewById(R.id.searchInSelectionSpinner);
searchInSelectionSpinner.setSelection(selectedPos); // title
searchInSelectionSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view,
int pos, long id) {
search();
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO: nothing to do (?)
}
});
// searchInArtists = (RadioButton) findViewById(R.id.searchInArtists);
// searchInAlbums = (RadioButton) findViewById(R.id.searchInAlbums);
// searchInFamousArtists = (RadioButton) findViewById(R.id.searchInSimilarArtists);
// searchInTitles = (RadioButton) findViewById(R.id.searchInTitles);
// RadioGroup radioGroup = (RadioGroup) findViewById(R.id.searchCriterion);
// radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {
//
// @Override
// public void onCheckedChanged(RadioGroup group, int checkedId) {
// search();
// }
// });
}
项目:triples
文件:StatisticsSelectorView.java
private void initSpinner() {
mSpinner = (Spinner) findViewById(R.id.period_spinner);
ArrayAdapter<CharSequence> adapter =
new ArrayAdapter<CharSequence>(getContext(), android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
initPeriodsMap();
for (String key : PERIODS.keySet()) {
adapter.add(key);
}
mSpinner.setAdapter(adapter);
mSpinner.setOnItemSelectedListener(
new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
String string = (String) parent.getItemAtPosition(pos);
mCurrentPeriod = PERIODS.get(string);
if (mOnPeriodChangeListener != null) {
mOnPeriodChangeListener.onPeriodChange(mCurrentPeriod);
}
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {}
});
mCurrentPeriod = PERIODS.get(mSpinner.getSelectedItem().toString());
}
项目:gundog-engine
文件:OnlineGameLayout.java
private Spinner generateSpinner(Context context, OnItemSelectedListener listener, int description, int[] choices) {
String[] mStrings = new String[choices.length];
Resources resources = context.getResources();
for (int i = 0; i < mStrings.length; i++) {
mStrings[i] = resources.getString(description) + ": " + resources.getString(choices[i]).toUpperCase();
}
Spinner speedSpinner = new Spinner(context);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(context, android.R.layout.simple_spinner_item, mStrings);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
speedSpinner.setAdapter(adapter);
speedSpinner.setOnItemSelectedListener(listener);
return speedSpinner;
}
项目:gundog-engine
文件:NewGameLayout.java
private Spinner generateSpinner(Context context, OnItemSelectedListener listener, int description, int[] choices) {
String[] mStrings = new String[choices.length];
Resources resources = context.getResources();
for (int i = 0; i < mStrings.length; i++) {
mStrings[i] = resources.getString(description) + ": " + resources.getString(choices[i]).toUpperCase();
}
Spinner speedSpinner = new Spinner(context);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(context, android.R.layout.simple_spinner_item, mStrings);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
speedSpinner.setAdapter(adapter);
speedSpinner.setOnItemSelectedListener(listener);
return speedSpinner;
}
项目:gundog-engine
文件:CampaignLevelLayout.java
private Spinner generateSpinner(Context context, OnItemSelectedListener listener, int description, int[] choices) {
String[] mStrings = new String[choices.length];
Resources resources = context.getResources();
for (int i = 0; i < mStrings.length; i++) {
mStrings[i] = resources.getString(description) + ": " + resources.getString(choices[i]).toUpperCase();
}
Spinner speedSpinner = new Spinner(context);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(context, android.R.layout.simple_spinner_item, mStrings);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
speedSpinner.setAdapter(adapter);
speedSpinner.setOnItemSelectedListener(listener);
return speedSpinner;
}
项目:BeeFramework_Android
文件:AbstractAQuery.java
/**
* Register a callback method for when an item is selected.
*
* @param listener The item selected listener.
* @return self
*/
public T itemSelected(OnItemSelectedListener listener){
if(view instanceof AdapterView){
AdapterView<?> alv = (AdapterView<?>) view;
alv.setOnItemSelectedListener(listener);
}
return self();
}
项目:q-mail
文件:AccountSetupIncoming.java
/**
* This is invoked only when the user makes changes to a widget, not when
* widgets are changed programmatically. (The logic is simpler when you know
* that this is the last thing called after an input change.)
*/
private void validateFields() {
AuthType authType = getSelectedAuthType();
boolean isAuthTypeExternal = (AuthType.EXTERNAL == authType);
ConnectionSecurity connectionSecurity = getSelectedSecurity();
boolean hasConnectionSecurity = (connectionSecurity != ConnectionSecurity.NONE);
if (isAuthTypeExternal && !hasConnectionSecurity) {
// Notify user of an invalid combination of AuthType.EXTERNAL & ConnectionSecurity.NONE
String toastText = getString(R.string.account_setup_incoming_invalid_setting_combo_notice,
getString(R.string.account_setup_incoming_auth_type_label),
AuthType.EXTERNAL.toString(),
getString(R.string.account_setup_incoming_security_label),
ConnectionSecurity.NONE.toString());
Toast.makeText(this, toastText, Toast.LENGTH_LONG).show();
// Reset the views back to their previous settings without recursing through here again
OnItemSelectedListener onItemSelectedListener = mAuthTypeView.getOnItemSelectedListener();
mAuthTypeView.setOnItemSelectedListener(null);
mAuthTypeView.setSelection(mCurrentAuthTypeViewPosition, false);
mAuthTypeView.setOnItemSelectedListener(onItemSelectedListener);
updateViewFromAuthType();
onItemSelectedListener = mSecurityTypeView.getOnItemSelectedListener();
mSecurityTypeView.setOnItemSelectedListener(null);
mSecurityTypeView.setSelection(mCurrentSecurityTypeViewPosition, false);
mSecurityTypeView.setOnItemSelectedListener(onItemSelectedListener);
updateAuthPlainTextFromSecurityType(getSelectedSecurity());
mPortView.removeTextChangedListener(validationTextWatcher);
mPortView.setText(mCurrentPortViewSetting);
mPortView.addTextChangedListener(validationTextWatcher);
authType = getSelectedAuthType();
isAuthTypeExternal = (AuthType.EXTERNAL == authType);
connectionSecurity = getSelectedSecurity();
hasConnectionSecurity = (connectionSecurity != ConnectionSecurity.NONE);
} else {
mCurrentAuthTypeViewPosition = mAuthTypeView.getSelectedItemPosition();
mCurrentSecurityTypeViewPosition = mSecurityTypeView.getSelectedItemPosition();
mCurrentPortViewSetting = mPortView.getText().toString();
}
boolean hasValidCertificateAlias = mClientCertificateSpinner.getAlias() != null;
boolean hasValidUserName = Utility.requiredFieldValid(mUsernameView);
boolean hasValidPasswordSettings = hasValidUserName
&& !isAuthTypeExternal
&& Utility.requiredFieldValid(mPasswordView);
boolean hasValidExternalAuthSettings = hasValidUserName
&& isAuthTypeExternal
&& hasConnectionSecurity
&& hasValidCertificateAlias;
mNextButton.setEnabled(Utility.domainFieldValid(mServerView)
&& Utility.requiredFieldValid(mPortView)
&& (hasValidPasswordSettings || hasValidExternalAuthSettings));
Utility.setCompoundDrawablesAlpha(mNextButton, mNextButton.isEnabled() ? 255 : 128);
}
项目:q-mail
文件:AccountSetupOutgoing.java
/**
* This is invoked only when the user makes changes to a widget, not when
* widgets are changed programmatically. (The logic is simpler when you know
* that this is the last thing called after an input change.)
*/
private void validateFields() {
AuthType authType = getSelectedAuthType();
boolean isAuthTypeExternal = (AuthType.EXTERNAL == authType);
ConnectionSecurity connectionSecurity = getSelectedSecurity();
boolean hasConnectionSecurity = (connectionSecurity != ConnectionSecurity.NONE);
if (isAuthTypeExternal && !hasConnectionSecurity) {
// Notify user of an invalid combination of AuthType.EXTERNAL & ConnectionSecurity.NONE
String toastText = getString(R.string.account_setup_outgoing_invalid_setting_combo_notice,
getString(R.string.account_setup_incoming_auth_type_label),
AuthType.EXTERNAL.toString(),
getString(R.string.account_setup_incoming_security_label),
ConnectionSecurity.NONE.toString());
Toast.makeText(this, toastText, Toast.LENGTH_LONG).show();
// Reset the views back to their previous settings without recursing through here again
OnItemSelectedListener onItemSelectedListener = mAuthTypeView.getOnItemSelectedListener();
mAuthTypeView.setOnItemSelectedListener(null);
mAuthTypeView.setSelection(mCurrentAuthTypeViewPosition, false);
mAuthTypeView.setOnItemSelectedListener(onItemSelectedListener);
updateViewFromAuthType();
onItemSelectedListener = mSecurityTypeView.getOnItemSelectedListener();
mSecurityTypeView.setOnItemSelectedListener(null);
mSecurityTypeView.setSelection(mCurrentSecurityTypeViewPosition, false);
mSecurityTypeView.setOnItemSelectedListener(onItemSelectedListener);
updateAuthPlainTextFromSecurityType(getSelectedSecurity());
mPortView.removeTextChangedListener(validationTextWatcher);
mPortView.setText(mCurrentPortViewSetting);
mPortView.addTextChangedListener(validationTextWatcher);
authType = getSelectedAuthType();
isAuthTypeExternal = (AuthType.EXTERNAL == authType);
connectionSecurity = getSelectedSecurity();
hasConnectionSecurity = (connectionSecurity != ConnectionSecurity.NONE);
} else {
mCurrentAuthTypeViewPosition = mAuthTypeView.getSelectedItemPosition();
mCurrentSecurityTypeViewPosition = mSecurityTypeView.getSelectedItemPosition();
mCurrentPortViewSetting = mPortView.getText().toString();
}
boolean hasValidCertificateAlias = mClientCertificateSpinner.getAlias() != null;
boolean hasValidUserName = Utility.requiredFieldValid(mUsernameView);
boolean hasValidPasswordSettings = hasValidUserName
&& !isAuthTypeExternal
&& Utility.requiredFieldValid(mPasswordView);
boolean hasValidExternalAuthSettings = hasValidUserName
&& isAuthTypeExternal
&& hasConnectionSecurity
&& hasValidCertificateAlias;
mNextButton
.setEnabled(Utility.domainFieldValid(mServerView)
&& Utility.requiredFieldValid(mPortView)
&& (!mRequireLoginView.isChecked()
|| hasValidPasswordSettings || hasValidExternalAuthSettings));
Utility.setCompoundDrawablesAlpha(mNextButton, mNextButton.isEnabled() ? 255 : 128);
}
项目:GitHub
文件:GridPickerView.java
public void setOnItemSelectedListener(OnItemSelectedListener onItemSelectedListener) {
this.onItemSelectedListener = onItemSelectedListener;
}
项目:GitHub
文件:GridPickerAdapter.java
public void setOnItemSelectedListener(OnItemSelectedListener onItemSelectedListener) {
this.onItemSelectedListener = onItemSelectedListener;
}
项目:GitHub
文件:GridPickerView.java
public void setOnItemSelectedListener(OnItemSelectedListener onItemSelectedListener) {
this.onItemSelectedListener = onItemSelectedListener;
}
项目:GitHub
文件:GridPickerAdapter.java
public void setOnItemSelectedListener(OnItemSelectedListener onItemSelectedListener) {
this.onItemSelectedListener = onItemSelectedListener;
}
项目:APIJSON-Android-RxJava
文件:GridPickerView.java
public void setOnItemSelectedListener(OnItemSelectedListener onItemSelectedListener) {
this.onItemSelectedListener = onItemSelectedListener;
}