当前位置: 首页>>代码示例>>Java>>正文


Java OnItemSelectedListener类代码示例

本文整理汇总了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);
}
 
开发者ID:axlecho,项目名称:tuxguitar,代码行数:20,代码来源:TGBrowserView.java

示例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) {
        }
    });
}
 
开发者ID:tiberiusteng,项目名称:financisto1-holo,代码行数:19,代码来源:DateFilterActivity.java

示例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) {
        }
    });
}
 
开发者ID:emmanuel-florent,项目名称:flowzr-android-black,代码行数:23,代码来源:DateFilterActivity.java

示例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) {
        }
    });
}
 
开发者ID:emmanuel-florent,项目名称:flowzr-android-black,代码行数:21,代码来源:DateFilterFragment.java

示例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);
}
 
开发者ID:b2renger,项目名称:PdDroidPublisher,代码行数:18,代码来源:MidiConfigDialog.java

示例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.
    }
  });
}
 
开发者ID:Vosie,项目名称:WikiCards,代码行数:22,代码来源:MainActivity.java

示例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) {
				}
			});
}
 
开发者ID:laaptu,项目名称:twitterwidget,代码行数:25,代码来源:TimeLineFragmentConfig.java

示例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);

}
 
开发者ID:cattong,项目名称:YiBo,代码行数:26,代码来源:AddAccountActivity.java

示例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);

	
}
 
开发者ID:starn,项目名称:encdroidMC,代码行数:36,代码来源:ConfigSyncActivity.java

示例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();
}
 
开发者ID:libit,项目名称:lr_dialer,代码行数:16,代码来源:AbstractAQuery.java

示例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();
	
}
 
开发者ID:bblue000,项目名称:ExoPlayerDemo,代码行数:17,代码来源:AbstractAQuery.java

示例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);
}
 
开发者ID:ltGuillaume,项目名称:DroidShows,代码行数:32,代码来源:DroidShows.java

示例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());
}
 
开发者ID:JSafaiyeh,项目名称:Fabric-Example-App-Android,代码行数:15,代码来源:MoPubAdAdapterTest.java

示例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);
}
 
开发者ID:JSafaiyeh,项目名称:Fabric-Example-App-Android,代码行数:15,代码来源:MoPubAdAdapterTest.java

示例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;

}
 
开发者ID:wstczlt,项目名称:palette,代码行数:17,代码来源:ViewHelper.java


注:本文中的android.widget.AdapterView.OnItemSelectedListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。