android.widget.Spinner.setOnItemSelectedListener()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(271)

本文整理了Java中android.widget.Spinner.setOnItemSelectedListener()方法的一些代码示例,展示了Spinner.setOnItemSelectedListener()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Spinner.setOnItemSelectedListener()方法的具体详情如下:
包路径:android.widget.Spinner
类名称:Spinner
方法名:setOnItemSelectedListener

Spinner.setOnItemSelectedListener介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

Spinner s = (Spinner)Util.findViewById(view, R.id.sound, R.id.spinner);
s.setAdapter(adapter);
s.setSelection(position, false);
s.setOnItemSelectedListener(listener);

代码示例来源:origin: stackoverflow.com

public class HelloSpinner extends Activity
{
 @Override
 public void onCreate(Bundle savedInstanceState)
 {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);

  Spinner spinner = (Spinner) findViewById(R.id.spinner);
  ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.planets_array,
//        android.R.layout.simple_spinner_item);
    R.layout.my_spinner_textview);
//    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  adapter.setDropDownViewResource(R.layout.my_spinner_textview);
  spinner.setAdapter(adapter);
  spinner.setOnItemSelectedListener(new MyOnItemSelectedListener());
 }

 //No other modification needed.

代码示例来源:origin: stackoverflow.com

@Override
public boolean onCreateOptionsMenu(Menu menu) {
  getMenuInflater().inflate(R.menu.menu_layout, menu);
  MenuItem item = menu.findItem(R.id.spinner);
  Spinner spinner = (Spinner) MenuItemCompat.getActionView(item);
  spinner.setAdapter(adapter); // set the adapter to provide layout of rows and content
  spinner.setOnItemSelectedListener(onItemSelectedListener); // set the listener, to perform actions based on item selection

代码示例来源:origin: TeamNewPipe/NewPipe

@Override
public void onDestroyView() {
  if (DEBUG) Log.d(TAG, "onDestroyView() called");
  spinnerToolbar.setOnItemSelectedListener(null);
  spinnerToolbar.setAdapter(null);
  super.onDestroyView();
}

代码示例来源:origin: stackoverflow.com

spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(this);

代码示例来源:origin: commonsguy/cw-omnibus

@Override
public void onCreate(Bundle state) {
 super.onCreate(state);
 setContentView(R.layout.main);
 selection=(TextView)findViewById(R.id.selection);
 
 Spinner spin=(Spinner)findViewById(R.id.spinner);
 spin.setOnItemSelectedListener(this);
 
 ArrayAdapter<String> aa=new ArrayAdapter<String>(this,
              android.R.layout.simple_spinner_item,
              items);
 
 aa.setDropDownViewResource(
  android.R.layout.simple_spinner_dropdown_item);
 spin.setAdapter(aa);
}

代码示例来源:origin: vinc3m1/RoundedImageView

@Override protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.example_activity);
 Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
 Spinner navSpinner = (Spinner) findViewById(R.id.spinner_nav);
 navSpinner.setAdapter(ArrayAdapter.createFromResource(
   navSpinner.getContext(),
   R.array.action_list,
   android.R.layout.simple_spinner_dropdown_item));
 navSpinner.setOnItemSelectedListener(this);
 if (savedInstanceState == null) {
  navSpinner.setSelection(0);
 }
}

代码示例来源:origin: commonsguy/cw-omnibus

@Override
public void onReady() {
 setContentView(R.layout.main);
 Spinner spin=findViewById(R.id.spinner);
 spin.setOnItemSelectedListener(this);
 ArrayAdapter<String> aa=new ArrayAdapter<String>(this,
  android.R.layout.simple_spinner_item,
  getResources().getStringArray(R.array.options));
 aa.setDropDownViewResource(
  android.R.layout.simple_spinner_dropdown_item);
 spin.setAdapter(aa);
 RecyclerView rv=findViewById(android.R.id.list);
 rv.setLayoutManager(new LinearLayoutManager(this));
 rv.addItemDecoration(new DividerItemDecoration(this,
  DividerItemDecoration.VERTICAL));
 adapter=new RVCursorAdapter(getLayoutInflater());
 rv.setAdapter(adapter);
}

代码示例来源:origin: stackoverflow.com

spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(this);

代码示例来源:origin: gabrielemariotti/RecyclerViewItemAnimators

spinner.setAdapter(adapter);
spinner.setSelection(1);
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
  @Override
  public void onItemSelected(AdapterView<?> adapterView, View view, int position, long l) {

代码示例来源:origin: gabrielemariotti/RecyclerViewItemAnimators

spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
  @Override
  public void onItemSelected(AdapterView<?> adapterView, View view, int position, long l) {

代码示例来源:origin: JohnPersano/SuperToasts

spinner.setAdapter(new ArrayAdapter<>(getActivity(),
    android.R.layout.simple_spinner_dropdown_item, getArguments()
    .getStringArray(ARG_ARRAY_ID)));
spinner.setSelection(PreferenceManager.getDefaultSharedPreferences(getActivity())
    .getInt(getArguments().getString(ARG_TITLE), 0));
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

代码示例来源:origin: stackoverflow.com

users);
mySpinner = (Spinner) findViewById(R.id.miSpinner);
mySpinner.setAdapter(adapter); // Set the custom adapter to the spinner
mySpinner.setOnItemSelectedListener(new OnItemSelectedListener() {

代码示例来源:origin: TeamNewPipe/NewPipe

private void setupActionBar(final StreamInfo info) {
  if (DEBUG) Log.d(TAG, "setupActionBarHandler() called with: info = [" + info + "]");
  boolean isExternalPlayerEnabled = PreferenceManager.getDefaultSharedPreferences(activity)
      .getBoolean(activity.getString(R.string.use_external_video_player_key), false);
  sortedVideoStreams = ListHelper.getSortedStreamVideosList(activity, info.getVideoStreams(), info.getVideoOnlyStreams(), false);
  selectedVideoStreamIndex = ListHelper.getDefaultResolutionIndex(activity, sortedVideoStreams);
  final StreamItemAdapter<VideoStream, Stream> streamsAdapter = new StreamItemAdapter<>(activity, new StreamSizeWrapper<>(sortedVideoStreams, activity), isExternalPlayerEnabled);
  spinnerToolbar.setAdapter(streamsAdapter);
  spinnerToolbar.setSelection(selectedVideoStreamIndex);
  spinnerToolbar.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
    @Override
    public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
      selectedVideoStreamIndex = position;
    }
    @Override
    public void onNothingSelected(AdapterView<?> parent) {
    }
  });
}

代码示例来源:origin: gabrielemariotti/RecyclerViewItemAnimators

spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
  @Override
  public void onItemSelected(AdapterView<?> adapterView, View view, int position, long l) {

代码示例来源:origin: gabrielemariotti/RecyclerViewItemAnimators

spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
  @Override
  public void onItemSelected(AdapterView<?> adapterView, View view, int position, long l) {

代码示例来源:origin: hidroh/materialistic

final Spinner spinner = (Spinner) holder.findViewById(R.id.spinner);
holder.itemView.setOnClickListener(v -> spinner.performClick());
spinner.setAdapter(new SpinnerAdapter() {
  @Override
  public View getDropDownView(int position, View convertView, ViewGroup parent) {
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
  @Override
  public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {

代码示例来源:origin: daniulive/SmarterStreaming

adapterScreenResolution
    .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
screenResolutionSelector.setAdapter(adapterScreenResolution);
    .setOnItemSelectedListener(new OnItemSelectedListener() {
recorderSelector.setAdapter(adapterRecoder);
    .setOnItemSelectedListener(new OnItemSelectedListener() {
    android.R.layout.simple_spinner_item, videoEncodeTypes);
adapterVideoEncodeType.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
videoEncodeTypeSelector.setAdapter(adapterVideoEncodeType);
videoEncodeTypeSelector.setOnItemSelectedListener(new OnItemSelectedListener() {

代码示例来源:origin: Piasy/BigImageViewer

spLoader.setAdapter(getArrayAdapter(IMAGE_LOADERS));
spLoader.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
  @Override
  public void onItemSelected(final AdapterView<?> parent, final View view,
spType.setAdapter(getArrayAdapter(IMAGE_TYPES));
spType.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
  @Override
  public void onItemSelected(final AdapterView<?> parent, final View view,

代码示例来源:origin: daniulive/SmarterStreaming

adapterResolution
    .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
cameraResolutionSelector.setAdapter(adapterResolution);
    .setOnItemSelectedListener(new OnItemSelectedListener() {
recorderSelector.setAdapter(adapterRecoder);
    .setOnItemSelectedListener(new OnItemSelectedListener() {

相关文章