當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。