android.widget.AdapterView.OnItemSelectedListener Java Examples

The following examples show how to use android.widget.AdapterView.OnItemSelectedListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AddAccountActivity.java    From YiBo with Apache License 2.0 6 votes vote down vote up
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);

}
 
Example #2
Source File: TGBrowserView.java    From tuxguitar with GNU Lesser General Public License v2.1 6 votes vote down vote up
@SuppressWarnings("unchecked")
public void refreshCollections(boolean forceDefaults) {
	ArrayAdapter<TGSelectableItem> arrayAdapter = new ArrayAdapter<TGSelectableItem>(findActivity(), android.R.layout.simple_spinner_item, createCollectionValues());
	arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

	TGBrowserCollection selectedCollection = (forceDefaults ? TGBrowserManager.getInstance(this.findContext()).getDefaultCollection() : this.findCurrentCollection());

	TGSelectableItem selectedItem = new TGSelectableItem(selectedCollection, 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);
	}
	spinner.setOnItemSelectedListener(listener);
	if( spinner.getSelectedItemPosition() != selectedItemPosition ) {
		spinner.setSelection(selectedItemPosition, false);
	}
}
 
Example #3
Source File: MidiConfigDialog.java    From PdDroidPublisher with GNU General Public License v3.0 6 votes vote down vote up
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);
}
 
Example #4
Source File: GridActivity.java    From CardUI with Apache License 2.0 5 votes vote down vote up
@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
                                
                        }

                        
                });
}
 
Example #5
Source File: FileSelector.java    From IPTVFree with Apache License 2.0 5 votes vote down vote up
private void prepareFilterSpinner(String[] fitlesFilter) {
	mFilterSpinner = (Spinner) mDialog.findViewById(R.id.fileFilter);
	if (fitlesFilter == null || fitlesFilter.length == 0) {
		fitlesFilter = new String[] { FileUtils.FILTER_ALLOW_ALL };
		mFilterSpinner.setEnabled(false);
	}
	ArrayAdapter<String> adapter = new ArrayAdapter<String>(mContext, R.layout.spinner_item, fitlesFilter);

	mFilterSpinner.setAdapter(adapter);
	OnItemSelectedListener onItemSelectedListener = new OnItemSelectedListener() {

		@Override
		public void onItemSelected(AdapterView<?> aAdapter, View aView, int arg2, long arg3) {
			TextView textViewItem = (TextView) aView;
			String filtr = textViewItem.getText().toString();
			makeList(mCurrentLocation, filtr);
		}

		@Override
		public void onNothingSelected(AdapterView<?> arg0) {

		}
	};
	mFilterSpinner.setOnItemSelectedListener(onItemSelectedListener);
}
 
Example #6
Source File: GridActivity.java    From CardUI with Apache License 2.0 5 votes vote down vote up
@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
                                
                        }

                        
                });
}
 
Example #7
Source File: StickyGridHeadersGridView.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void setOnItemSelectedListener(OnItemSelectedListener listener) {
    this.mOnItemSelectedListener = listener;
    super.setOnItemSelectedListener(this);
}
 
Example #8
Source File: SpinnerActivity.java    From codeexamples-android with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Initializes the application and the activity. 1) Sets the view 2) Reads
 * the spinner's backing data from the string resources file 3) Instantiates
 * a callback listener for handling selection from the spinner Notice that
 * this method includes code that can be uncommented to force tests to fail.
 * 
 * This method overrides the default onCreate() method for an Activity.
 * 
 * @see android.app.Activity#onCreate(android.os.Bundle)
 */
@Override
public void onCreate(Bundle savedInstanceState) {

	/**
	 * derived classes that use onCreate() overrides must always call the
	 * super constructor
	 */
	super.onCreate(savedInstanceState);

	setContentView(R.layout.main);

	Spinner spinner = (Spinner) findViewById(R.id.Spinner01);

	/*
	 * Create a backing mLocalAdapter for the Spinner from a list of the
	 * planets. The list is defined by XML in the strings.xml file.
	 */

	this.mAdapter = ArrayAdapter.createFromResource(this, R.array.Planets,
			android.R.layout.simple_spinner_dropdown_item);

	/*
	 * Attach the mLocalAdapter to the spinner.
	 */

	spinner.setAdapter(this.mAdapter);

	/*
	 * Create a listener that is triggered when Android detects the user has
	 * selected an item in the Spinner.
	 */

	OnItemSelectedListener spinnerListener = new myOnItemSelectedListener(
			this, this.mAdapter);

	/*
	 * Attach the listener to the Spinner.
	 */

	spinner.setOnItemSelectedListener(spinnerListener);

	/*
	 * To demonstrate a failure in the preConditions test, uncomment the
	 * following line. The test will fail because the selection listener for
	 * the Spinner is not set.
	 */
	// spinner.setOnItemSelectedListener(null);

}
 
Example #9
Source File: SpinnerActivity.java    From androidtestdebug with MIT License 4 votes vote down vote up
/**
 * Initializes the application and the activity.
 * 1) Sets the view
 * 2) Reads the spinner's backing data from the string resources file
 * 3) Instantiates a callback listener for handling selection from the
 *    spinner
 * Notice that this method includes code that can be uncommented to force
 * tests to fail.
 *
 * This method overrides the default onCreate() method for an Activity.
 *
 * @see android.app.Activity#onCreate(android.os.Bundle)
 */
@Override
public void onCreate(Bundle savedInstanceState) {

    /**
     * derived classes that use onCreate() overrides must always call the super constructor
     */
    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);

    Spinner spinner = (Spinner) findViewById(R.id.Spinner01);

    /*
     * Create a backing mLocalAdapter for the Spinner from a list of the
     * planets. The list is defined by XML in the strings.xml file.
     */

    this.mAdapter = ArrayAdapter.createFromResource(this, R.array.Planets,
            android.R.layout.simple_spinner_dropdown_item);

    /*
     * Attach the mLocalAdapter to the spinner.
     */

    spinner.setAdapter(this.mAdapter);

    /*
     * Create a listener that is triggered when Android detects the
     * user has selected an item in the Spinner.
     */

    OnItemSelectedListener spinnerListener = new myOnItemSelectedListener(this,this.mAdapter);

    /*
     * Attach the listener to the Spinner.
     */

    spinner.setOnItemSelectedListener(spinnerListener);


    /*
     * To demonstrate a failure in the preConditions test,
     * uncomment the following line.
     * The test will fail because the selection listener for the
     * Spinner is not set.
     */
     // spinner.setOnItemSelectedListener(null);

}
 
Example #10
Source File: StickyGridHeadersGridView.java    From StickyGridHeaders with Apache License 2.0 4 votes vote down vote up
@Override
public void setOnItemSelectedListener(android.widget.AdapterView.OnItemSelectedListener listener) {
    this.mOnItemSelectedListener = listener;
    super.setOnItemSelectedListener(this);
}
 
Example #11
Source File: ActivityPublishData.java    From gsn with GNU General Public License v3.0 4 votes vote down vote up
public void renderModeList() {

		List<String> list = new ArrayList<>();
		for (String s : STRATEGY) {
			list.add(s);
		}
		ArrayAdapter<String> dataAdapter = new ArrayAdapter<>(this, R.layout.spinner_item, list);
		dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		modeSpinner.setAdapter(dataAdapter);
		modeSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
            public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
                if (pos != 0) {
                    fromdateEditText.setVisibility(View.GONE);
                    todateEditText.setVisibility(View.GONE);
                    totimeEditText.setVisibility(View.GONE);
                    fromtimeEditText.setVisibility(View.GONE);
                    publishButton.setVisibility(View.GONE);
                    findViewById(R.id.textViewFrom).setVisibility(View.GONE);
                    findViewById(R.id.textViewTo).setVisibility(View.GONE);
                    iterationTime.setVisibility(View.VISIBLE);
                    findViewById(R.id.textIterationTime).setVisibility(View.VISIBLE);
                } else {
                    fromdateEditText.setVisibility(View.VISIBLE);
                    todateEditText.setVisibility(View.VISIBLE);
                    totimeEditText.setVisibility(View.VISIBLE);
                    fromtimeEditText.setVisibility(View.VISIBLE);
                    publishButton.setVisibility(View.VISIBLE);
                    findViewById(R.id.textViewFrom).setVisibility(View.VISIBLE);
                    findViewById(R.id.textViewTo).setVisibility(View.VISIBLE);
                    iterationTime.setVisibility(View.GONE);
                    findViewById(R.id.textIterationTime).setVisibility(View.GONE);
                }
            }

            @Override
            public void onNothingSelected(AdapterView<?> arg0) {
            }
        });
		if (dr != null) {
			modeSpinner.setSelection(dr.getMode());
		}
	}
 
Example #12
Source File: StickyGridHeadersGridView.java    From UltimateAndroid with Apache License 2.0 4 votes vote down vote up
@Override
public void setOnItemSelectedListener(OnItemSelectedListener listener) {
    this.mOnItemSelectedListener = listener;
    super.setOnItemSelectedListener(this);
}
 
Example #13
Source File: StickyGridHeadersGridView.java    From UltimateAndroid with Apache License 2.0 4 votes vote down vote up
@Override
public void setOnItemSelectedListener(OnItemSelectedListener listener) {
    this.mOnItemSelectedListener = listener;
    super.setOnItemSelectedListener(this);
}
 
Example #14
Source File: SpinnerWidget.java    From commcare-android with Apache License 2.0 4 votes vote down vote up
public SpinnerWidget(Context context, FormEntryPrompt prompt) {
    super(context, prompt);

    mItems = getSelectChoices();
    spinner = new Spinner(context);
    choices = new String[mItems.size()];

    for (int i = 0; i < mItems.size(); i++) {
        choices[i] = prompt.getSelectChoiceText(mItems.get(i));
    }

    // The spinner requires a custom adapter. It is defined below
    SpinnerAdapter adapter =
            new SpinnerAdapter(getContext(), android.R.layout.simple_spinner_item,
                    getChoicesWithEmptyFirstSlot(choices),
                    TypedValue.COMPLEX_UNIT_DIP, mQuestionFontSize);

    spinner.setAdapter(adapter);
    spinner.setPrompt(prompt.getQuestionText());
    spinner.setEnabled(!prompt.isReadOnly());
    spinner.setFocusable(!prompt.isReadOnly());

    // Fill in previous answer
    String s = null;
    if (prompt.getAnswerValue() != null) {
        s = ((Selection)prompt.getAnswerValue().getValue()).getValue();
    }

    if (s != null) {
        for (int i = 0; i < mItems.size(); ++i) {
            String sMatch = mItems.get(i).getValue();
            if (sMatch.equals(s)) {
                // Workaround to a really weird spinner bug that triggers onItemSelected
                // in the initial selection of spinner even though no listener is set.
                // https://stackoverflow.com/a/17336944/6671572
                spinner.setSelection(i+1, false);
            }
        }
    }

    spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
            widgetEntryChanged();
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
            //do nothing here
        }

    });

    addView(spinner);

}
 
Example #15
Source File: Spinner.java    From AndroidMaterialValidation with Apache License 2.0 4 votes vote down vote up
public final OnItemSelectedListener getOnItemSelectedListener() {
    return itemSelectedListener;
}
 
Example #16
Source File: TopicFragment.java    From android-discourse with Apache License 2.0 4 votes vote down vote up
public OnItemSelectedListener getListener() {
    return mNotifListener;
}
 
Example #17
Source File: PinnedHeaderListView.java    From TurboLauncher with Apache License 2.0 4 votes vote down vote up
@Override
public void setOnItemSelectedListener(OnItemSelectedListener listener) {
    mOnItemSelectedListener = listener;
    super.setOnItemSelectedListener(this);
}
 
Example #18
Source File: PinnedHeaderListView.java    From Trebuchet with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void setOnItemSelectedListener(OnItemSelectedListener listener) {
    mOnItemSelectedListener = listener;
    super.setOnItemSelectedListener(this);
}
 
Example #19
Source File: SpinnerHelper.java    From AndroidAPS with GNU Affero General Public License v3.0 4 votes vote down vote up
public void setOnItemSelectedListener(OnItemSelectedListener listener) {
    proxiedItemSelectedListener = listener;
    setTouchListener();
    spinner.setOnItemSelectedListener(listener == null ? null : this);
}
 
Example #20
Source File: LetvGallery.java    From letv with Apache License 2.0 4 votes vote down vote up
public void removeSelectedListener(OnItemSelectedListener itemSelectedListener) {
    this.listeners.remove(itemSelectedListener);
}
 
Example #21
Source File: LetvGallery.java    From letv with Apache License 2.0 4 votes vote down vote up
public void addSelectedListener(OnItemSelectedListener itemSelectedListener) {
    this.listeners.add(itemSelectedListener);
}
 
Example #22
Source File: Spinner.java    From AndroidMaterialValidation with Apache License 2.0 2 votes vote down vote up
/**
 * Register a callback to be invoked when an item in this AdapterView has been selected.
 *
 * @param listener
 *         The callback that will run
 */
public final void setOnItemSelectedListener(final OnItemSelectedListener listener) {
    this.itemSelectedListener = listener;
}
 
Example #23
Source File: Spinner.java    From BotLibre with Eclipse Public License 1.0 2 votes vote down vote up
public void setOnItemSelectedListener(OnItemSelectedListener listener) {
	
}
 
Example #24
Source File: ListView.java    From BotLibre with Eclipse Public License 1.0 2 votes vote down vote up
public void setOnItemSelectedListener(OnItemSelectedListener listener) {
	
}
 
Example #25
Source File: Spinner.java    From BotLibre with Eclipse Public License 1.0 2 votes vote down vote up
public void setOnItemSelectedListener(OnItemSelectedListener listener) {
	
}
 
Example #26
Source File: ListView.java    From BotLibre with Eclipse Public License 1.0 2 votes vote down vote up
public void setOnItemSelectedListener(OnItemSelectedListener listener) {
	
}
 
Example #27
Source File: ListPopupWindow.java    From android_9.0.0_r45 with Apache License 2.0 2 votes vote down vote up
/**
 * Sets a listener to receive events when a list item is selected.
 *
 * @param selectedListener Listener to register.
 *
 * @see ListView#setOnItemSelectedListener(OnItemSelectedListener)
 */
public void setOnItemSelectedListener(@Nullable OnItemSelectedListener selectedListener) {
    mItemSelectedListener = selectedListener;
}