Java Code Examples for android.widget.AdapterView#OnItemSelectedListener

The following examples show how to use android.widget.AdapterView#OnItemSelectedListener . These examples are extracted from open source projects. 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 Project: EosCommander   File: GetTableFragment.java    License: MIT License 6 votes vote down vote up
private AppCompatSpinner setDropDownList(int dropDownListId, List<String> data, AdapterView.OnItemSelectedListener itemSelectedListener) {
    AppCompatSpinner spinner = mRootView.findViewById( dropDownListId );
    if ( spinner == null ) {
        return null;
    }

    ArrayAdapter<String> adapter = new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_item, data);
    adapter.setDropDownViewResource( android.R.layout.simple_spinner_dropdown_item );
    spinner.setAdapter( adapter );

    if ( itemSelectedListener != null ) {
        spinner.setOnItemSelectedListener(itemSelectedListener);
    }

    return spinner;
}
 
Example 2
private void setUpColorSpinner(Spinner spinner, AdapterView.OnItemSelectedListener onItemSelectedListener) {
    if (mColorSpinnerAdapter == null) {
        int[] colorsArray = getResources().getIntArray(R.array.widget_bg_colors);
        Integer[] colors = new Integer[colorsArray.length];
        for (int i = 0; i < colorsArray.length; i++) {
            colors[i] = Integer.valueOf(colorsArray[i]);
        }
        mColorSpinnerAdapter = new ColorSpinnerAdapter(this, colors);
    }

    spinner.setAdapter(mColorSpinnerAdapter);
    spinner.setOnItemSelectedListener(onItemSelectedListener);
    spinner.setSelection(0);
}
 
Example 3
Source Project: biermacht   File: SettingsActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void configureSpinnerListener() {
  spinnerListener = new AdapterView.OnItemSelectedListener() {
    @Override
    public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {

    }

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

    }
  };
}
 
Example 4
Source Project: Pimp_my_Z1   File: Card.java    License: GNU General Public License v2.0 5 votes vote down vote up
public Card(String title, String desc, String prop, int currentItem, ArrayList<String> spinnerEntries, ActionBarActivity fa, AdapterView.OnItemSelectedListener onItemSelectedListener) {
    this.title = title;
    this.desc = desc;
    this.spinnerEntries = spinnerEntries;
    this.fa = fa;
    this.onItemSelectedListener = onItemSelectedListener;
    this.prop = prop;
    this.currentItem = currentItem;
}
 
Example 5
Source Project: commonadapter   File: ViewHolderImpl.java    License: MIT License 4 votes vote down vote up
public void setOnItemSelectedClickListener(int viewId, AdapterView.OnItemSelectedListener listener) {
    AdapterView view = findViewById(viewId);
    view.setOnItemSelectedListener(listener);
}
 
Example 6
@Override
public void configureSpinnerListener() {

  mashTypeSpinnerListener = new AdapterView.OnItemSelectedListener() {

    public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
      mProfile.setMashType(mashTypeArray.get(position));

      if (mashTypeArray.get(position).equals(MashProfile.MASH_TYPE_BIAB)) {
        // Set the spargeTypeSpinner to BIAB.
        spargeTypeSpinner.setSelection(spargeTypeArray.indexOf(MashProfile.SPARGE_TYPE_BIAB));

        // Make some undesired views disappear.
        spargeTypeSpinner.setVisibility(View.GONE);
        spargeTempView.setVisibility(View.GONE);
        tunTempView.setVisibility(View.GONE);
      }
      else {
        spargeTypeSpinner.setVisibility(View.VISIBLE);
        spargeTempView.setVisibility(View.VISIBLE);
        tunTempView.setVisibility(View.VISIBLE);
      }

      callback.call();
    }

    public void onNothingSelected(AdapterView<?> parentView) {
    }

  };

  spargeTypeSpinnerListener = new AdapterView.OnItemSelectedListener() {

    public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position,
                               long id) {
      mProfile.setSpargeType(spargeTypeArray.get(position));
      callback.call();
    }

    public void onNothingSelected(AdapterView<?> parentView) {
    }

  };
}
 
Example 7
Source Project: FoodOrdering   File: RewriteAlertDialog.java    License: Apache License 2.0 4 votes vote down vote up
public Builder setOnItemSelectedListener(
		final AdapterView.OnItemSelectedListener listener) {
	P.mOnItemSelectedListener = listener;
	return this;
}
 
Example 8
@NonNull
@Override
public ViewFinder setOnItemSelectedListener(final int ID, final AdapterView.OnItemSelectedListener listener) {
	((AdapterView) find(ID)).setOnItemSelectedListener(listener);
	return this;
}
 
Example 9
public CardSpinner(String title, String desc, String color, String prop, int currentItem, ArrayList<String> spinnerEntries, ActionBarActivity fa, AdapterView.OnItemSelectedListener onItemSelectedListener) {
    super(title, desc, color, prop, currentItem, spinnerEntries, fa, onItemSelectedListener);
}
 
Example 10
public OnItemSelectedListenerWrapper(AdapterView.OnItemSelectedListener listener) {
    lastPosition = 0;
    this.listener = listener;
}
 
Example 11
Source Project: anvil   File: DSL.java    License: MIT License 4 votes vote down vote up
public static Void onItemSelected(AdapterView.OnItemSelectedListener arg) {
  return BaseDSL.attr("onItemSelected", arg);
}
 
Example 12
/**
 * Set Spinner Item Selected callback
 *
 * @param listener
 */
public void setOnSpinnerItemSelectedListener(AdapterView.OnItemSelectedListener listener) {
    mPropertySpinner.setOnItemSelectedListener(listener);
}
 
Example 13
Source Project: NewXmPluginSDK   File: MLAlertDialog.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Sets a listener to be invoked when an item in the list is selected.
 * 
 * @param listener The listener to be invoked.
 * @return This Builder object to allow for chaining of calls to set
 *         methods
 * @see AdapterView#setOnItemSelectedListener(AdapterView.OnItemSelectedListener)
 */
public Builder setOnItemSelectedListener(final AdapterView.OnItemSelectedListener listener) {
    P.mOnItemSelectedListener = listener;
    return this;
}
 
Example 14
Source Project: material   File: ListPopupWindow.java    License: 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(AdapterView.OnItemSelectedListener)
 */
public void setOnItemSelectedListener(AdapterView.OnItemSelectedListener selectedListener) {
    mItemSelectedListener = selectedListener;
}
 
Example 15
Source Project: BaseProject   File: BaseViewHolder.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Sets the listview or gridview's item selected click listener of the view
 *
 * @param viewId   The view id.
 * @param listener The item selected click listener;
 * @return The BaseViewHolder for chaining.
 */
public BaseViewHolder setOnItemSelectedClickListener(@IdRes int viewId, AdapterView.OnItemSelectedListener listener) {
    AdapterView view = getView(viewId);
    view.setOnItemSelectedListener(listener);
    return this;
}
 
Example 16
Source Project: demo4Fish   File: BaseViewHolder.java    License: MIT License 2 votes vote down vote up
/**
 * Sets the listview or gridview's item selected click listener of the view
 *
 * @param viewId   The view id.
 * @param listener The item selected click listener;
 * @return The BaseViewHolder for chaining.
 */
public BaseViewHolder setOnItemSelectedClickListener(int viewId, AdapterView.OnItemSelectedListener listener) {
    AdapterView view = getView(viewId);
    view.setOnItemSelectedListener(listener);
    return this;
}
 
Example 17
Source Project: holoaccent   File: AccentAlertDialog.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Sets a listener to be invoked when an item in the list is selected.
 * 
 * @param listener The listener to be invoked.
 * @see AdapterView#setOnItemSelectedListener(android.widget.AdapterView.OnItemSelectedListener)
 *
 * @return This Builder object to allow for chaining of calls to set methods
 */
public Builder setOnItemSelectedListener(final AdapterView.OnItemSelectedListener listener) {
	mBuilder.setOnItemSelectedListener(listener);
    return this;
}
 
Example 18
Source Project: JD-Test   File: BaseViewHolder.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Sets the listview or gridview's item selected click listener of the view
 *
 * @param viewId   The view id.
 * @param listener The item selected click listener;
 * @return The BaseViewHolder for chaining.
 */
public BaseViewHolder setOnItemSelectedClickListener(int viewId, AdapterView.OnItemSelectedListener listener) {
    AdapterView view = getView(viewId);
    view.setOnItemSelectedListener(listener);
    return this;
}
 
Example 19
Source Project: MDPreference   File: EditText.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * <p>Sets the listener that will be notified when the user selects an item
 * in the drop down list.</p>
 * <p>Only work when autoComplete mode is {@link #AUTOCOMPLETE_MODE_SINGLE} or {@link #AUTOCOMPLETE_MODE_MULTI}</p>
 *
 * @param l the item selected listener
 */
public void setOnItemSelectedListener(AdapterView.OnItemSelectedListener l) {
    if(mAutoCompleteMode == AUTOCOMPLETE_MODE_NONE)
        return;
    ((AutoCompleteTextView)mInputView).setOnItemSelectedListener(l);
}
 
Example 20
Source Project: NIM_Android_UIKit   File: BaseViewHolder.java    License: MIT License 2 votes vote down vote up
/**
 * Sets the listview or gridview's item selected click listener of the view
 *
 * @param viewId   The view id.
 * @param listener The item selected click listener;
 * @return The BaseViewHolder for chaining.
 */
public BaseViewHolder setOnItemSelectedClickListener(int viewId, AdapterView.OnItemSelectedListener listener) {
    AdapterView view = getView(viewId);
    view.setOnItemSelectedListener(listener);
    return this;
}