本文整理汇总了Java中android.widget.AdapterView.OnItemSelectedListener类的典型用法代码示例。如果您正苦于以下问题:Java OnItemSelectedListener类的具体用法?Java OnItemSelectedListener怎么用?Java OnItemSelectedListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OnItemSelectedListener类属于android.widget.AdapterView包,在下文中一共展示了OnItemSelectedListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: refreshCollections
import android.widget.AdapterView.OnItemSelectedListener; //导入依赖的package包/类
@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);
}
示例2: createPeriodsSpinner
import android.widget.AdapterView.OnItemSelectedListener; //导入依赖的package包/类
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) {
}
});
}
示例3: createPeriodsSpinner
import android.widget.AdapterView.OnItemSelectedListener; //导入依赖的package包/类
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) {
}
});
}
示例4: createPeriodsSpinner
import android.widget.AdapterView.OnItemSelectedListener; //导入依赖的package包/类
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) {
}
});
}
示例5: refreshInputList
import android.widget.AdapterView.OnItemSelectedListener; //导入依赖的package包/类
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);
}
示例6: initCategorySpinner
import android.widget.AdapterView.OnItemSelectedListener; //导入依赖的package包/类
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.
}
});
}
示例7: onActivityCreated
import android.widget.AdapterView.OnItemSelectedListener; //导入依赖的package包/类
@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) {
}
});
}
示例8: bindEvent
import android.widget.AdapterView.OnItemSelectedListener; //导入依赖的package包/类
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);
}
示例9: onCreate
import android.widget.AdapterView.OnItemSelectedListener; //导入依赖的package包/类
@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);
}
示例10: itemSelected
import android.widget.AdapterView.OnItemSelectedListener; //导入依赖的package包/类
/**
* 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();
}
示例11: itemSelected
import android.widget.AdapterView.OnItemSelectedListener; //导入依赖的package包/类
/**
* 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();
}
示例12: arrangeActionBar
import android.widget.AdapterView.OnItemSelectedListener; //导入依赖的package包/类
@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);
}
示例13: setOnItemSelectedListener_withAdPosition_shouldNotCallListener
import android.widget.AdapterView.OnItemSelectedListener; //导入依赖的package包/类
@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());
}
示例14: setOnItemSelectedListener_withNonAdPosition_shouldCallListener
import android.widget.AdapterView.OnItemSelectedListener; //导入依赖的package包/类
@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);
}
示例15: itemSelected
import android.widget.AdapterView.OnItemSelectedListener; //导入依赖的package包/类
/**
* 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;
}