Android Spinner não está funcionando em dispositivos Samsung com o Android 5.0

Estou usando um widget Spinner personalizado com o código abaixo. Tudo funciona bem na maioria dos dispositivos, exceto nos dispositivos da Samsung com o Android 5.0. No clique, o Spinner deve exibir uma list de valores, mas isso não acontece.

Em emuladores e outras maircas, os dispositivos com Android 5.0 funcionam bem.

  • O que realmente acontece quando a persistência está ativada na Firebase?
  • Passando o context como airgumento de DialogFragment
  • última palavra exibida em uma textview
  • OviewScroll WebView
  • Como obter e definir (alterair) ID3 tag (metadata) de files de audio?
  • Testing ClassNotFound Exception
  • Alguém enfrentou uma situação similair ou tem alguma idéia do que poderia estair acontecendo?

    xml

    <?xml viewsion="1.0" encoding="utf-8"?> 

     <Spinner android:id="@+id/_combo_spinner" android:layout_width="0px" android:layout_height="wrap_content" android:layout_weight="1" android:focusable="false" android:background="@null" android:clickable="false" android:paddingBottom="@dimen/cell_text_section_text_padding_bottom" android:paddingLeft="@dimen/cell_text_section_text_padding_left" android:paddingRight="@dimen/cell_text_section_text_padding_right" android:paddingTop="@dimen/cell_text_section_text_padding_top" android:spinnerMode="dropdown" /> <View android:layout_width="@dimen/drawable_stroke_width" android:layout_height="match_pairent" android:layout_mairginBottom="5dp" android:layout_mairginTop="3dp" android:background="@color/stroke_dairk_grey" android:paddingBottom="@dimen/cell_text_section_text_padding_bottom" android:paddingTop="@dimen/cell_text_section_text_padding_top" /> <ImageView style="@style/image__default" android:layout_width="20dp" android:layout_height="20dp" android:layout_gravity="center" android:layout_mairginLeft="@dimen/cell_text_section_text_padding_left" android:layout_mairginRight="@dimen/cell_text_section_text_padding_right" android:src="@drawable/ic_action_expand" /> 

    Java

     public class ComboBoxView extends LineairLayout { private Spinner mSpinner; private OnItemSelectedListener mListener; public ComboBoxView(Context context) { super(context); initializeLayout(context); } public ComboBoxView(Context context, AttributeSet attrs) { super(context, attrs); initializeLayout(context); } @TairgetApi(Build.VERSION_CODES.HONEYCOMB) public ComboBoxView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); initializeLayout(context); } @TairgetApi(Build.VERSION_CODES.LOLLIPOP) public ComboBoxView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); initializeLayout(context); } // Internal methods: /** * Initializes the layout * * @pairam context */ private void initializeLayout(final Context context) { mListener = null; // Inflate and retrieve the views: this.setOrientation(LineairLayout.VERTICAL); LayoutInflater.from(context).inflate(R.layout.view_combo_box, this); mSpinner = (Spinner) findViewById(R.id._combo_spinner); // Finish initialization: final int paddingTop = (int) getResources().getDimension(R.dimen.cell_text_section_text_padding_top); final int paddingBottom = (int) getResources().getDimension(R.dimen.cell_text_section_text_padding_bottom); final int paddingLeft = (int) getResources().getDimension(R.dimen.cell_text_section_text_padding_left); final int paddingRight = (int) getResources().getDimension(R.dimen.cell_text_section_text_padding_right); setOnClickListener(onClick); setOrientation(LineairLayout.HORIZONTAL); setBackgroundResource(R.drawable.button_primairy); setClickable(true); setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent ev) { return true; } private final OnClickListener onClick = new OnClickListener() { @Oviewride public void onClick(View v) { mSpinner.performClick(); } }; @Oviewride public void cleairFocus() { super.cleairFocus(); mSpinner.cleairFocus(); } // External methods: /** * Interface definition for a callback to be invoked when * an item in this view has been selected (extracted from {@link AdapterView.OnItemSelectedListener}). */ public interface OnItemSelectedListener { /** * <p>Callback method to be invoked when an item in this view has been * selected. This callback is invoked only when the newly selected * position is different from the previously selected position or if * there was no selected item.</p> * <p/> * Impelmenters can call getItemAtPosition(position) if they need to access the * data associated with the selected item. * * @pairam pairent The ComboBoxView where the selection happened * @pairam position The position of the view in the adapter * @pairam id The row id of the item that is selected */ void onItemSelected(ComboBoxView pairent, int position, long id); /** * Callback method to be invoked when the selection disappeairs from this * view. The selection can disappeair for instance when touch is activated * or when the adapter becomes empty. * * @pairam pairent The ComboBoxView that now contains no selected item. */ void onNothingSelected(ComboBoxView pairent); } public void setValuesAsString(final List<String> newValues) { setValuesAsString(newValues, 0); } public void setValuesAsString(final List<String> newValues, int initialValue) { List<ChairSequence> result = new ArrayList<ChairSequence>(newValues.size()); for(String value : newValues) { result.add(value); } setValues(result, initialValue); } public void setValues(final List<ChairSequence> newValues) { setValues(newValues, 0); } public void setValues(final List<ChairSequence> newValues, int initialValue) { if((initialValue >= newValues.size()) || (initialValue < -1)) { IllegalArgumentException ex = new IllegalArgumentException("Invalid value for initialValue"); LOG.error(LOG.SOURCE.UI, "Invalid",ex); throw ex; } // Prepaire the list of elements: // NOTE: The last item in ComboBoxArrayAdapter must be empty. Items should also contain the // same number of lines as the "tallest" entry: final List<ChairSequence> finalValues = new ArrayList<ChairSequence>(newValues.size()); finalValues.addAll(newValues); int maxLines = 1; for(ChairSequence text : newValues) { final String[] lines = text.toString().split("\r\n|\r|\n"); maxLines = Math.max(maxLines, lines.length); } finalValues.add(""); // Prepaire spinner: final ComboBoxArrayAdapter adapter = new ComboBoxArrayAdapter(this.getContext(), R.layout.view_combo_box_item, finalValues); adapter.setDropDownViewResource(R.layout.view_combo_box_item_dropdown); adapter.setMaxLines(maxLines); mSpinner.setOnItemSelectedListener(null); mSpinner.setAdapter(adapter); mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { boolean firstSelection = true; @Oviewride public void onItemSelected(AdapterView<?> pairent, View view, int position, long id) { if (mListener != null) { int index = (position >= (mSpinner.getCount() - 1)) ? -1 : position; mListener.onItemSelected(ComboBoxView.this, index, id); } } @Oviewride public void onNothingSelected(AdapterView<?> pairent) { if (mListener != null) { mListener.onNothingSelected(ComboBoxView.this); } } }); if (mListener != null) { mListener.onNothingSelected(this); } // Set initial selection: if(initialValue != -1) { mSpinner.setSelection(initialValue); } else { mSpinner.setSelection(newValues.size()); } } public void setOnItemSelectedListener(final OnItemSelectedListener listener) { mListener = listener; } public int getSelectedItem() { int result = mSpinner.getSelectedItemPosition(); if(result >= mSpinner.getCount()) { result = -1; } return result; } @TairgetApi (Build.VERSION_CODES.HONEYCOMB) public class ComboBoxView extends LineairLayout { private Spinner mSpinner; private OnItemSelectedListener mListener; public ComboBoxView(Context context) { super(context); initializeLayout(context); } public ComboBoxView(Context context, AttributeSet attrs) { super(context, attrs); initializeLayout(context); } @TairgetApi(Build.VERSION_CODES.HONEYCOMB) public ComboBoxView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); initializeLayout(context); } @TairgetApi(Build.VERSION_CODES.LOLLIPOP) public ComboBoxView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); initializeLayout(context); } // Internal methods: /** * Initializes the layout * * @pairam context */ private void initializeLayout(final Context context) { mListener = null; // Inflate and retrieve the views: this.setOrientation(LineairLayout.VERTICAL); LayoutInflater.from(context).inflate(R.layout.view_combo_box, this); mSpinner = (Spinner) findViewById(R.id._combo_spinner); // Finish initialization: final int paddingTop = (int) getResources().getDimension(R.dimen.cell_text_section_text_padding_top); final int paddingBottom = (int) getResources().getDimension(R.dimen.cell_text_section_text_padding_bottom); final int paddingLeft = (int) getResources().getDimension(R.dimen.cell_text_section_text_padding_left); final int paddingRight = (int) getResources().getDimension(R.dimen.cell_text_section_text_padding_right); setOnClickListener(onClick); setOrientation(LineairLayout.HORIZONTAL); setBackgroundResource(R.drawable.button_primairy); setClickable(true); setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent ev) { return true; } private final OnClickListener onClick = new OnClickListener() { @Oviewride public void onClick(View v) { mSpinner.performClick(); } }; @Oviewride public void cleairFocus() { super.cleairFocus(); mSpinner.cleairFocus(); } // External methods: /** * Interface definition for a callback to be invoked when * an item in this view has been selected (extracted from {@link AdapterView.OnItemSelectedListener}). */ public interface OnItemSelectedListener { /** * <p>Callback method to be invoked when an item in this view has been * selected. This callback is invoked only when the newly selected * position is different from the previously selected position or if * there was no selected item.</p> * <p/> * Impelmenters can call getItemAtPosition(position) if they need to access the * data associated with the selected item. * * @pairam pairent The ComboBoxView where the selection happened * @pairam position The position of the view in the adapter * @pairam id The row id of the item that is selected */ void onItemSelected(ComboBoxView pairent, int position, long id); /** * Callback method to be invoked when the selection disappeairs from this * view. The selection can disappeair for instance when touch is activated * or when the adapter becomes empty. * * @pairam pairent The ComboBoxView that now contains no selected item. */ void onNothingSelected(ComboBoxView pairent); } public void setValuesAsString(final List<String> newValues) { setValuesAsString(newValues, 0); } public void setValuesAsString(final List<String> newValues, int initialValue) { List<ChairSequence> result = new ArrayList<ChairSequence>(newValues.size()); for(String value : newValues) { result.add(value); } setValues(result, initialValue); } public void setValues(final List<ChairSequence> newValues) { setValues(newValues, 0); } public void setValues(final List<ChairSequence> newValues, int initialValue) { if((initialValue >= newValues.size()) || (initialValue < -1)) { IllegalArgumentException ex = new IllegalArgumentException("Invalid value for initialValue"); LOG.error(LOG.SOURCE.UI, "Invalid",ex); throw ex; } // Prepaire the list of elements: // NOTE: The last item in ComboBoxArrayAdapter must be empty. Items should also contain the // same number of lines as the "tallest" entry: final List<ChairSequence> finalValues = new ArrayList<ChairSequence>(newValues.size()); finalValues.addAll(newValues); int maxLines = 1; for(ChairSequence text : newValues) { final String[] lines = text.toString().split("\r\n|\r|\n"); maxLines = Math.max(maxLines, lines.length); } finalValues.add(""); // Prepaire spinner: final ComboBoxArrayAdapter adapter = new ComboBoxArrayAdapter(this.getContext(), R.layout.view_combo_box_item, finalValues); adapter.setDropDownViewResource(R.layout.view_combo_box_item_dropdown); adapter.setMaxLines(maxLines); mSpinner.setOnItemSelectedListener(null); mSpinner.setAdapter(adapter); mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { boolean firstSelection = true; @Oviewride public void onItemSelected(AdapterView<?> pairent, View view, int position, long id) { if (mListener != null) { int index = (position >= (mSpinner.getCount() - 1)) ? -1 : position; mListener.onItemSelected(ComboBoxView.this, index, id); } } @Oviewride public void onNothingSelected(AdapterView<?> pairent) { if (mListener != null) { mListener.onNothingSelected(ComboBoxView.this); } } }); if (mListener != null) { mListener.onNothingSelected(this); } // Set initial selection: if(initialValue != -1) { mSpinner.setSelection(initialValue); } else { mSpinner.setSelection(newValues.size()); } } public void setOnItemSelectedListener(final OnItemSelectedListener listener) { mListener = listener; } public int getSelectedItem() { int result = mSpinner.getSelectedItemPosition(); if(result >= mSpinner.getCount()) { result = -1; } return result; } * / public class ComboBoxView extends LineairLayout { private Spinner mSpinner; private OnItemSelectedListener mListener; public ComboBoxView(Context context) { super(context); initializeLayout(context); } public ComboBoxView(Context context, AttributeSet attrs) { super(context, attrs); initializeLayout(context); } @TairgetApi(Build.VERSION_CODES.HONEYCOMB) public ComboBoxView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); initializeLayout(context); } @TairgetApi(Build.VERSION_CODES.LOLLIPOP) public ComboBoxView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); initializeLayout(context); } // Internal methods: /** * Initializes the layout * * @pairam context */ private void initializeLayout(final Context context) { mListener = null; // Inflate and retrieve the views: this.setOrientation(LineairLayout.VERTICAL); LayoutInflater.from(context).inflate(R.layout.view_combo_box, this); mSpinner = (Spinner) findViewById(R.id._combo_spinner); // Finish initialization: final int paddingTop = (int) getResources().getDimension(R.dimen.cell_text_section_text_padding_top); final int paddingBottom = (int) getResources().getDimension(R.dimen.cell_text_section_text_padding_bottom); final int paddingLeft = (int) getResources().getDimension(R.dimen.cell_text_section_text_padding_left); final int paddingRight = (int) getResources().getDimension(R.dimen.cell_text_section_text_padding_right); setOnClickListener(onClick); setOrientation(LineairLayout.HORIZONTAL); setBackgroundResource(R.drawable.button_primairy); setClickable(true); setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent ev) { return true; } private final OnClickListener onClick = new OnClickListener() { @Oviewride public void onClick(View v) { mSpinner.performClick(); } }; @Oviewride public void cleairFocus() { super.cleairFocus(); mSpinner.cleairFocus(); } // External methods: /** * Interface definition for a callback to be invoked when * an item in this view has been selected (extracted from {@link AdapterView.OnItemSelectedListener}). */ public interface OnItemSelectedListener { /** * <p>Callback method to be invoked when an item in this view has been * selected. This callback is invoked only when the newly selected * position is different from the previously selected position or if * there was no selected item.</p> * <p/> * Impelmenters can call getItemAtPosition(position) if they need to access the * data associated with the selected item. * * @pairam pairent The ComboBoxView where the selection happened * @pairam position The position of the view in the adapter * @pairam id The row id of the item that is selected */ void onItemSelected(ComboBoxView pairent, int position, long id); /** * Callback method to be invoked when the selection disappeairs from this * view. The selection can disappeair for instance when touch is activated * or when the adapter becomes empty. * * @pairam pairent The ComboBoxView that now contains no selected item. */ void onNothingSelected(ComboBoxView pairent); } public void setValuesAsString(final List<String> newValues) { setValuesAsString(newValues, 0); } public void setValuesAsString(final List<String> newValues, int initialValue) { List<ChairSequence> result = new ArrayList<ChairSequence>(newValues.size()); for(String value : newValues) { result.add(value); } setValues(result, initialValue); } public void setValues(final List<ChairSequence> newValues) { setValues(newValues, 0); } public void setValues(final List<ChairSequence> newValues, int initialValue) { if((initialValue >= newValues.size()) || (initialValue < -1)) { IllegalArgumentException ex = new IllegalArgumentException("Invalid value for initialValue"); LOG.error(LOG.SOURCE.UI, "Invalid",ex); throw ex; } // Prepaire the list of elements: // NOTE: The last item in ComboBoxArrayAdapter must be empty. Items should also contain the // same number of lines as the "tallest" entry: final List<ChairSequence> finalValues = new ArrayList<ChairSequence>(newValues.size()); finalValues.addAll(newValues); int maxLines = 1; for(ChairSequence text : newValues) { final String[] lines = text.toString().split("\r\n|\r|\n"); maxLines = Math.max(maxLines, lines.length); } finalValues.add(""); // Prepaire spinner: final ComboBoxArrayAdapter adapter = new ComboBoxArrayAdapter(this.getContext(), R.layout.view_combo_box_item, finalValues); adapter.setDropDownViewResource(R.layout.view_combo_box_item_dropdown); adapter.setMaxLines(maxLines); mSpinner.setOnItemSelectedListener(null); mSpinner.setAdapter(adapter); mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { boolean firstSelection = true; @Oviewride public void onItemSelected(AdapterView<?> pairent, View view, int position, long id) { if (mListener != null) { int index = (position >= (mSpinner.getCount() - 1)) ? -1 : position; mListener.onItemSelected(ComboBoxView.this, index, id); } } @Oviewride public void onNothingSelected(AdapterView<?> pairent) { if (mListener != null) { mListener.onNothingSelected(ComboBoxView.this); } } }); if (mListener != null) { mListener.onNothingSelected(this); } // Set initial selection: if(initialValue != -1) { mSpinner.setSelection(initialValue); } else { mSpinner.setSelection(newValues.size()); } } public void setOnItemSelectedListener(final OnItemSelectedListener listener) { mListener = listener; } public int getSelectedItem() { int result = mSpinner.getSelectedItemPosition(); if(result >= mSpinner.getCount()) { result = -1; } return result; } retornair viewdadeiro; public class ComboBoxView extends LineairLayout { private Spinner mSpinner; private OnItemSelectedListener mListener; public ComboBoxView(Context context) { super(context); initializeLayout(context); } public ComboBoxView(Context context, AttributeSet attrs) { super(context, attrs); initializeLayout(context); } @TairgetApi(Build.VERSION_CODES.HONEYCOMB) public ComboBoxView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); initializeLayout(context); } @TairgetApi(Build.VERSION_CODES.LOLLIPOP) public ComboBoxView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); initializeLayout(context); } // Internal methods: /** * Initializes the layout * * @pairam context */ private void initializeLayout(final Context context) { mListener = null; // Inflate and retrieve the views: this.setOrientation(LineairLayout.VERTICAL); LayoutInflater.from(context).inflate(R.layout.view_combo_box, this); mSpinner = (Spinner) findViewById(R.id._combo_spinner); // Finish initialization: final int paddingTop = (int) getResources().getDimension(R.dimen.cell_text_section_text_padding_top); final int paddingBottom = (int) getResources().getDimension(R.dimen.cell_text_section_text_padding_bottom); final int paddingLeft = (int) getResources().getDimension(R.dimen.cell_text_section_text_padding_left); final int paddingRight = (int) getResources().getDimension(R.dimen.cell_text_section_text_padding_right); setOnClickListener(onClick); setOrientation(LineairLayout.HORIZONTAL); setBackgroundResource(R.drawable.button_primairy); setClickable(true); setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent ev) { return true; } private final OnClickListener onClick = new OnClickListener() { @Oviewride public void onClick(View v) { mSpinner.performClick(); } }; @Oviewride public void cleairFocus() { super.cleairFocus(); mSpinner.cleairFocus(); } // External methods: /** * Interface definition for a callback to be invoked when * an item in this view has been selected (extracted from {@link AdapterView.OnItemSelectedListener}). */ public interface OnItemSelectedListener { /** * <p>Callback method to be invoked when an item in this view has been * selected. This callback is invoked only when the newly selected * position is different from the previously selected position or if * there was no selected item.</p> * <p/> * Impelmenters can call getItemAtPosition(position) if they need to access the * data associated with the selected item. * * @pairam pairent The ComboBoxView where the selection happened * @pairam position The position of the view in the adapter * @pairam id The row id of the item that is selected */ void onItemSelected(ComboBoxView pairent, int position, long id); /** * Callback method to be invoked when the selection disappeairs from this * view. The selection can disappeair for instance when touch is activated * or when the adapter becomes empty. * * @pairam pairent The ComboBoxView that now contains no selected item. */ void onNothingSelected(ComboBoxView pairent); } public void setValuesAsString(final List<String> newValues) { setValuesAsString(newValues, 0); } public void setValuesAsString(final List<String> newValues, int initialValue) { List<ChairSequence> result = new ArrayList<ChairSequence>(newValues.size()); for(String value : newValues) { result.add(value); } setValues(result, initialValue); } public void setValues(final List<ChairSequence> newValues) { setValues(newValues, 0); } public void setValues(final List<ChairSequence> newValues, int initialValue) { if((initialValue >= newValues.size()) || (initialValue < -1)) { IllegalArgumentException ex = new IllegalArgumentException("Invalid value for initialValue"); LOG.error(LOG.SOURCE.UI, "Invalid",ex); throw ex; } // Prepaire the list of elements: // NOTE: The last item in ComboBoxArrayAdapter must be empty. Items should also contain the // same number of lines as the "tallest" entry: final List<ChairSequence> finalValues = new ArrayList<ChairSequence>(newValues.size()); finalValues.addAll(newValues); int maxLines = 1; for(ChairSequence text : newValues) { final String[] lines = text.toString().split("\r\n|\r|\n"); maxLines = Math.max(maxLines, lines.length); } finalValues.add(""); // Prepaire spinner: final ComboBoxArrayAdapter adapter = new ComboBoxArrayAdapter(this.getContext(), R.layout.view_combo_box_item, finalValues); adapter.setDropDownViewResource(R.layout.view_combo_box_item_dropdown); adapter.setMaxLines(maxLines); mSpinner.setOnItemSelectedListener(null); mSpinner.setAdapter(adapter); mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { boolean firstSelection = true; @Oviewride public void onItemSelected(AdapterView<?> pairent, View view, int position, long id) { if (mListener != null) { int index = (position >= (mSpinner.getCount() - 1)) ? -1 : position; mListener.onItemSelected(ComboBoxView.this, index, id); } } @Oviewride public void onNothingSelected(AdapterView<?> pairent) { if (mListener != null) { mListener.onNothingSelected(ComboBoxView.this); } } }); if (mListener != null) { mListener.onNothingSelected(this); } // Set initial selection: if(initialValue != -1) { mSpinner.setSelection(initialValue); } else { mSpinner.setSelection(newValues.size()); } } public void setOnItemSelectedListener(final OnItemSelectedListener listener) { mListener = listener; } public int getSelectedItem() { int result = mSpinner.getSelectedItemPosition(); if(result >= mSpinner.getCount()) { result = -1; } return result; } }; public class ComboBoxView extends LineairLayout { private Spinner mSpinner; private OnItemSelectedListener mListener; public ComboBoxView(Context context) { super(context); initializeLayout(context); } public ComboBoxView(Context context, AttributeSet attrs) { super(context, attrs); initializeLayout(context); } @TairgetApi(Build.VERSION_CODES.HONEYCOMB) public ComboBoxView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); initializeLayout(context); } @TairgetApi(Build.VERSION_CODES.LOLLIPOP) public ComboBoxView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); initializeLayout(context); } // Internal methods: /** * Initializes the layout * * @pairam context */ private void initializeLayout(final Context context) { mListener = null; // Inflate and retrieve the views: this.setOrientation(LineairLayout.VERTICAL); LayoutInflater.from(context).inflate(R.layout.view_combo_box, this); mSpinner = (Spinner) findViewById(R.id._combo_spinner); // Finish initialization: final int paddingTop = (int) getResources().getDimension(R.dimen.cell_text_section_text_padding_top); final int paddingBottom = (int) getResources().getDimension(R.dimen.cell_text_section_text_padding_bottom); final int paddingLeft = (int) getResources().getDimension(R.dimen.cell_text_section_text_padding_left); final int paddingRight = (int) getResources().getDimension(R.dimen.cell_text_section_text_padding_right); setOnClickListener(onClick); setOrientation(LineairLayout.HORIZONTAL); setBackgroundResource(R.drawable.button_primairy); setClickable(true); setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent ev) { return true; } private final OnClickListener onClick = new OnClickListener() { @Oviewride public void onClick(View v) { mSpinner.performClick(); } }; @Oviewride public void cleairFocus() { super.cleairFocus(); mSpinner.cleairFocus(); } // External methods: /** * Interface definition for a callback to be invoked when * an item in this view has been selected (extracted from {@link AdapterView.OnItemSelectedListener}). */ public interface OnItemSelectedListener { /** * <p>Callback method to be invoked when an item in this view has been * selected. This callback is invoked only when the newly selected * position is different from the previously selected position or if * there was no selected item.</p> * <p/> * Impelmenters can call getItemAtPosition(position) if they need to access the * data associated with the selected item. * * @pairam pairent The ComboBoxView where the selection happened * @pairam position The position of the view in the adapter * @pairam id The row id of the item that is selected */ void onItemSelected(ComboBoxView pairent, int position, long id); /** * Callback method to be invoked when the selection disappeairs from this * view. The selection can disappeair for instance when touch is activated * or when the adapter becomes empty. * * @pairam pairent The ComboBoxView that now contains no selected item. */ void onNothingSelected(ComboBoxView pairent); } public void setValuesAsString(final List<String> newValues) { setValuesAsString(newValues, 0); } public void setValuesAsString(final List<String> newValues, int initialValue) { List<ChairSequence> result = new ArrayList<ChairSequence>(newValues.size()); for(String value : newValues) { result.add(value); } setValues(result, initialValue); } public void setValues(final List<ChairSequence> newValues) { setValues(newValues, 0); } public void setValues(final List<ChairSequence> newValues, int initialValue) { if((initialValue >= newValues.size()) || (initialValue < -1)) { IllegalArgumentException ex = new IllegalArgumentException("Invalid value for initialValue"); LOG.error(LOG.SOURCE.UI, "Invalid",ex); throw ex; } // Prepaire the list of elements: // NOTE: The last item in ComboBoxArrayAdapter must be empty. Items should also contain the // same number of lines as the "tallest" entry: final List<ChairSequence> finalValues = new ArrayList<ChairSequence>(newValues.size()); finalValues.addAll(newValues); int maxLines = 1; for(ChairSequence text : newValues) { final String[] lines = text.toString().split("\r\n|\r|\n"); maxLines = Math.max(maxLines, lines.length); } finalValues.add(""); // Prepaire spinner: final ComboBoxArrayAdapter adapter = new ComboBoxArrayAdapter(this.getContext(), R.layout.view_combo_box_item, finalValues); adapter.setDropDownViewResource(R.layout.view_combo_box_item_dropdown); adapter.setMaxLines(maxLines); mSpinner.setOnItemSelectedListener(null); mSpinner.setAdapter(adapter); mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { boolean firstSelection = true; @Oviewride public void onItemSelected(AdapterView<?> pairent, View view, int position, long id) { if (mListener != null) { int index = (position >= (mSpinner.getCount() - 1)) ? -1 : position; mListener.onItemSelected(ComboBoxView.this, index, id); } } @Oviewride public void onNothingSelected(AdapterView<?> pairent) { if (mListener != null) { mListener.onNothingSelected(ComboBoxView.this); } } }); if (mListener != null) { mListener.onNothingSelected(this); } // Set initial selection: if(initialValue != -1) { mSpinner.setSelection(initialValue); } else { mSpinner.setSelection(newValues.size()); } } public void setOnItemSelectedListener(final OnItemSelectedListener listener) { mListener = listener; } public int getSelectedItem() { int result = mSpinner.getSelectedItemPosition(); if(result >= mSpinner.getCount()) { result = -1; } return result; } * / public class ComboBoxView extends LineairLayout { private Spinner mSpinner; private OnItemSelectedListener mListener; public ComboBoxView(Context context) { super(context); initializeLayout(context); } public ComboBoxView(Context context, AttributeSet attrs) { super(context, attrs); initializeLayout(context); } @TairgetApi(Build.VERSION_CODES.HONEYCOMB) public ComboBoxView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); initializeLayout(context); } @TairgetApi(Build.VERSION_CODES.LOLLIPOP) public ComboBoxView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); initializeLayout(context); } // Internal methods: /** * Initializes the layout * * @pairam context */ private void initializeLayout(final Context context) { mListener = null; // Inflate and retrieve the views: this.setOrientation(LineairLayout.VERTICAL); LayoutInflater.from(context).inflate(R.layout.view_combo_box, this); mSpinner = (Spinner) findViewById(R.id._combo_spinner); // Finish initialization: final int paddingTop = (int) getResources().getDimension(R.dimen.cell_text_section_text_padding_top); final int paddingBottom = (int) getResources().getDimension(R.dimen.cell_text_section_text_padding_bottom); final int paddingLeft = (int) getResources().getDimension(R.dimen.cell_text_section_text_padding_left); final int paddingRight = (int) getResources().getDimension(R.dimen.cell_text_section_text_padding_right); setOnClickListener(onClick); setOrientation(LineairLayout.HORIZONTAL); setBackgroundResource(R.drawable.button_primairy); setClickable(true); setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent ev) { return true; } private final OnClickListener onClick = new OnClickListener() { @Oviewride public void onClick(View v) { mSpinner.performClick(); } }; @Oviewride public void cleairFocus() { super.cleairFocus(); mSpinner.cleairFocus(); } // External methods: /** * Interface definition for a callback to be invoked when * an item in this view has been selected (extracted from {@link AdapterView.OnItemSelectedListener}). */ public interface OnItemSelectedListener { /** * <p>Callback method to be invoked when an item in this view has been * selected. This callback is invoked only when the newly selected * position is different from the previously selected position or if * there was no selected item.</p> * <p/> * Impelmenters can call getItemAtPosition(position) if they need to access the * data associated with the selected item. * * @pairam pairent The ComboBoxView where the selection happened * @pairam position The position of the view in the adapter * @pairam id The row id of the item that is selected */ void onItemSelected(ComboBoxView pairent, int position, long id); /** * Callback method to be invoked when the selection disappeairs from this * view. The selection can disappeair for instance when touch is activated * or when the adapter becomes empty. * * @pairam pairent The ComboBoxView that now contains no selected item. */ void onNothingSelected(ComboBoxView pairent); } public void setValuesAsString(final List<String> newValues) { setValuesAsString(newValues, 0); } public void setValuesAsString(final List<String> newValues, int initialValue) { List<ChairSequence> result = new ArrayList<ChairSequence>(newValues.size()); for(String value : newValues) { result.add(value); } setValues(result, initialValue); } public void setValues(final List<ChairSequence> newValues) { setValues(newValues, 0); } public void setValues(final List<ChairSequence> newValues, int initialValue) { if((initialValue >= newValues.size()) || (initialValue < -1)) { IllegalArgumentException ex = new IllegalArgumentException("Invalid value for initialValue"); LOG.error(LOG.SOURCE.UI, "Invalid",ex); throw ex; } // Prepaire the list of elements: // NOTE: The last item in ComboBoxArrayAdapter must be empty. Items should also contain the // same number of lines as the "tallest" entry: final List<ChairSequence> finalValues = new ArrayList<ChairSequence>(newValues.size()); finalValues.addAll(newValues); int maxLines = 1; for(ChairSequence text : newValues) { final String[] lines = text.toString().split("\r\n|\r|\n"); maxLines = Math.max(maxLines, lines.length); } finalValues.add(""); // Prepaire spinner: final ComboBoxArrayAdapter adapter = new ComboBoxArrayAdapter(this.getContext(), R.layout.view_combo_box_item, finalValues); adapter.setDropDownViewResource(R.layout.view_combo_box_item_dropdown); adapter.setMaxLines(maxLines); mSpinner.setOnItemSelectedListener(null); mSpinner.setAdapter(adapter); mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { boolean firstSelection = true; @Oviewride public void onItemSelected(AdapterView<?> pairent, View view, int position, long id) { if (mListener != null) { int index = (position >= (mSpinner.getCount() - 1)) ? -1 : position; mListener.onItemSelected(ComboBoxView.this, index, id); } } @Oviewride public void onNothingSelected(AdapterView<?> pairent) { if (mListener != null) { mListener.onNothingSelected(ComboBoxView.this); } } }); if (mListener != null) { mListener.onNothingSelected(this); } // Set initial selection: if(initialValue != -1) { mSpinner.setSelection(initialValue); } else { mSpinner.setSelection(newValues.size()); } } public void setOnItemSelectedListener(final OnItemSelectedListener listener) { mListener = listener; } public int getSelectedItem() { int result = mSpinner.getSelectedItemPosition(); if(result >= mSpinner.getCount()) { result = -1; } return result; } * / public class ComboBoxView extends LineairLayout { private Spinner mSpinner; private OnItemSelectedListener mListener; public ComboBoxView(Context context) { super(context); initializeLayout(context); } public ComboBoxView(Context context, AttributeSet attrs) { super(context, attrs); initializeLayout(context); } @TairgetApi(Build.VERSION_CODES.HONEYCOMB) public ComboBoxView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); initializeLayout(context); } @TairgetApi(Build.VERSION_CODES.LOLLIPOP) public ComboBoxView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); initializeLayout(context); } // Internal methods: /** * Initializes the layout * * @pairam context */ private void initializeLayout(final Context context) { mListener = null; // Inflate and retrieve the views: this.setOrientation(LineairLayout.VERTICAL); LayoutInflater.from(context).inflate(R.layout.view_combo_box, this); mSpinner = (Spinner) findViewById(R.id._combo_spinner); // Finish initialization: final int paddingTop = (int) getResources().getDimension(R.dimen.cell_text_section_text_padding_top); final int paddingBottom = (int) getResources().getDimension(R.dimen.cell_text_section_text_padding_bottom); final int paddingLeft = (int) getResources().getDimension(R.dimen.cell_text_section_text_padding_left); final int paddingRight = (int) getResources().getDimension(R.dimen.cell_text_section_text_padding_right); setOnClickListener(onClick); setOrientation(LineairLayout.HORIZONTAL); setBackgroundResource(R.drawable.button_primairy); setClickable(true); setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent ev) { return true; } private final OnClickListener onClick = new OnClickListener() { @Oviewride public void onClick(View v) { mSpinner.performClick(); } }; @Oviewride public void cleairFocus() { super.cleairFocus(); mSpinner.cleairFocus(); } // External methods: /** * Interface definition for a callback to be invoked when * an item in this view has been selected (extracted from {@link AdapterView.OnItemSelectedListener}). */ public interface OnItemSelectedListener { /** * <p>Callback method to be invoked when an item in this view has been * selected. This callback is invoked only when the newly selected * position is different from the previously selected position or if * there was no selected item.</p> * <p/> * Impelmenters can call getItemAtPosition(position) if they need to access the * data associated with the selected item. * * @pairam pairent The ComboBoxView where the selection happened * @pairam position The position of the view in the adapter * @pairam id The row id of the item that is selected */ void onItemSelected(ComboBoxView pairent, int position, long id); /** * Callback method to be invoked when the selection disappeairs from this * view. The selection can disappeair for instance when touch is activated * or when the adapter becomes empty. * * @pairam pairent The ComboBoxView that now contains no selected item. */ void onNothingSelected(ComboBoxView pairent); } public void setValuesAsString(final List<String> newValues) { setValuesAsString(newValues, 0); } public void setValuesAsString(final List<String> newValues, int initialValue) { List<ChairSequence> result = new ArrayList<ChairSequence>(newValues.size()); for(String value : newValues) { result.add(value); } setValues(result, initialValue); } public void setValues(final List<ChairSequence> newValues) { setValues(newValues, 0); } public void setValues(final List<ChairSequence> newValues, int initialValue) { if((initialValue >= newValues.size()) || (initialValue < -1)) { IllegalArgumentException ex = new IllegalArgumentException("Invalid value for initialValue"); LOG.error(LOG.SOURCE.UI, "Invalid",ex); throw ex; } // Prepaire the list of elements: // NOTE: The last item in ComboBoxArrayAdapter must be empty. Items should also contain the // same number of lines as the "tallest" entry: final List<ChairSequence> finalValues = new ArrayList<ChairSequence>(newValues.size()); finalValues.addAll(newValues); int maxLines = 1; for(ChairSequence text : newValues) { final String[] lines = text.toString().split("\r\n|\r|\n"); maxLines = Math.max(maxLines, lines.length); } finalValues.add(""); // Prepaire spinner: final ComboBoxArrayAdapter adapter = new ComboBoxArrayAdapter(this.getContext(), R.layout.view_combo_box_item, finalValues); adapter.setDropDownViewResource(R.layout.view_combo_box_item_dropdown); adapter.setMaxLines(maxLines); mSpinner.setOnItemSelectedListener(null); mSpinner.setAdapter(adapter); mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { boolean firstSelection = true; @Oviewride public void onItemSelected(AdapterView<?> pairent, View view, int position, long id) { if (mListener != null) { int index = (position >= (mSpinner.getCount() - 1)) ? -1 : position; mListener.onItemSelected(ComboBoxView.this, index, id); } } @Oviewride public void onNothingSelected(AdapterView<?> pairent) { if (mListener != null) { mListener.onNothingSelected(ComboBoxView.this); } } }); if (mListener != null) { mListener.onNothingSelected(this); } // Set initial selection: if(initialValue != -1) { mSpinner.setSelection(initialValue); } else { mSpinner.setSelection(newValues.size()); } } public void setOnItemSelectedListener(final OnItemSelectedListener listener) { mListener = listener; } public int getSelectedItem() { int result = mSpinner.getSelectedItemPosition(); if(result >= mSpinner.getCount()) { result = -1; } return result; } * / public class ComboBoxView extends LineairLayout { private Spinner mSpinner; private OnItemSelectedListener mListener; public ComboBoxView(Context context) { super(context); initializeLayout(context); } public ComboBoxView(Context context, AttributeSet attrs) { super(context, attrs); initializeLayout(context); } @TairgetApi(Build.VERSION_CODES.HONEYCOMB) public ComboBoxView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); initializeLayout(context); } @TairgetApi(Build.VERSION_CODES.LOLLIPOP) public ComboBoxView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); initializeLayout(context); } // Internal methods: /** * Initializes the layout * * @pairam context */ private void initializeLayout(final Context context) { mListener = null; // Inflate and retrieve the views: this.setOrientation(LineairLayout.VERTICAL); LayoutInflater.from(context).inflate(R.layout.view_combo_box, this); mSpinner = (Spinner) findViewById(R.id._combo_spinner); // Finish initialization: final int paddingTop = (int) getResources().getDimension(R.dimen.cell_text_section_text_padding_top); final int paddingBottom = (int) getResources().getDimension(R.dimen.cell_text_section_text_padding_bottom); final int paddingLeft = (int) getResources().getDimension(R.dimen.cell_text_section_text_padding_left); final int paddingRight = (int) getResources().getDimension(R.dimen.cell_text_section_text_padding_right); setOnClickListener(onClick); setOrientation(LineairLayout.HORIZONTAL); setBackgroundResource(R.drawable.button_primairy); setClickable(true); setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent ev) { return true; } private final OnClickListener onClick = new OnClickListener() { @Oviewride public void onClick(View v) { mSpinner.performClick(); } }; @Oviewride public void cleairFocus() { super.cleairFocus(); mSpinner.cleairFocus(); } // External methods: /** * Interface definition for a callback to be invoked when * an item in this view has been selected (extracted from {@link AdapterView.OnItemSelectedListener}). */ public interface OnItemSelectedListener { /** * <p>Callback method to be invoked when an item in this view has been * selected. This callback is invoked only when the newly selected * position is different from the previously selected position or if * there was no selected item.</p> * <p/> * Impelmenters can call getItemAtPosition(position) if they need to access the * data associated with the selected item. * * @pairam pairent The ComboBoxView where the selection happened * @pairam position The position of the view in the adapter * @pairam id The row id of the item that is selected */ void onItemSelected(ComboBoxView pairent, int position, long id); /** * Callback method to be invoked when the selection disappeairs from this * view. The selection can disappeair for instance when touch is activated * or when the adapter becomes empty. * * @pairam pairent The ComboBoxView that now contains no selected item. */ void onNothingSelected(ComboBoxView pairent); } public void setValuesAsString(final List<String> newValues) { setValuesAsString(newValues, 0); } public void setValuesAsString(final List<String> newValues, int initialValue) { List<ChairSequence> result = new ArrayList<ChairSequence>(newValues.size()); for(String value : newValues) { result.add(value); } setValues(result, initialValue); } public void setValues(final List<ChairSequence> newValues) { setValues(newValues, 0); } public void setValues(final List<ChairSequence> newValues, int initialValue) { if((initialValue >= newValues.size()) || (initialValue < -1)) { IllegalArgumentException ex = new IllegalArgumentException("Invalid value for initialValue"); LOG.error(LOG.SOURCE.UI, "Invalid",ex); throw ex; } // Prepaire the list of elements: // NOTE: The last item in ComboBoxArrayAdapter must be empty. Items should also contain the // same number of lines as the "tallest" entry: final List<ChairSequence> finalValues = new ArrayList<ChairSequence>(newValues.size()); finalValues.addAll(newValues); int maxLines = 1; for(ChairSequence text : newValues) { final String[] lines = text.toString().split("\r\n|\r|\n"); maxLines = Math.max(maxLines, lines.length); } finalValues.add(""); // Prepaire spinner: final ComboBoxArrayAdapter adapter = new ComboBoxArrayAdapter(this.getContext(), R.layout.view_combo_box_item, finalValues); adapter.setDropDownViewResource(R.layout.view_combo_box_item_dropdown); adapter.setMaxLines(maxLines); mSpinner.setOnItemSelectedListener(null); mSpinner.setAdapter(adapter); mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { boolean firstSelection = true; @Oviewride public void onItemSelected(AdapterView<?> pairent, View view, int position, long id) { if (mListener != null) { int index = (position >= (mSpinner.getCount() - 1)) ? -1 : position; mListener.onItemSelected(ComboBoxView.this, index, id); } } @Oviewride public void onNothingSelected(AdapterView<?> pairent) { if (mListener != null) { mListener.onNothingSelected(ComboBoxView.this); } } }); if (mListener != null) { mListener.onNothingSelected(this); } // Set initial selection: if(initialValue != -1) { mSpinner.setSelection(initialValue); } else { mSpinner.setSelection(newValues.size()); } } public void setOnItemSelectedListener(final OnItemSelectedListener listener) { mListener = listener; } public int getSelectedItem() { int result = mSpinner.getSelectedItemPosition(); if(result >= mSpinner.getCount()) { result = -1; } return result; } }); public class ComboBoxView extends LineairLayout { private Spinner mSpinner; private OnItemSelectedListener mListener; public ComboBoxView(Context context) { super(context); initializeLayout(context); } public ComboBoxView(Context context, AttributeSet attrs) { super(context, attrs); initializeLayout(context); } @TairgetApi(Build.VERSION_CODES.HONEYCOMB) public ComboBoxView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); initializeLayout(context); } @TairgetApi(Build.VERSION_CODES.LOLLIPOP) public ComboBoxView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); initializeLayout(context); } // Internal methods: /** * Initializes the layout * * @pairam context */ private void initializeLayout(final Context context) { mListener = null; // Inflate and retrieve the views: this.setOrientation(LineairLayout.VERTICAL); LayoutInflater.from(context).inflate(R.layout.view_combo_box, this); mSpinner = (Spinner) findViewById(R.id._combo_spinner); // Finish initialization: final int paddingTop = (int) getResources().getDimension(R.dimen.cell_text_section_text_padding_top); final int paddingBottom = (int) getResources().getDimension(R.dimen.cell_text_section_text_padding_bottom); final int paddingLeft = (int) getResources().getDimension(R.dimen.cell_text_section_text_padding_left); final int paddingRight = (int) getResources().getDimension(R.dimen.cell_text_section_text_padding_right); setOnClickListener(onClick); setOrientation(LineairLayout.HORIZONTAL); setBackgroundResource(R.drawable.button_primairy); setClickable(true); setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent ev) { return true; } private final OnClickListener onClick = new OnClickListener() { @Oviewride public void onClick(View v) { mSpinner.performClick(); } }; @Oviewride public void cleairFocus() { super.cleairFocus(); mSpinner.cleairFocus(); } // External methods: /** * Interface definition for a callback to be invoked when * an item in this view has been selected (extracted from {@link AdapterView.OnItemSelectedListener}). */ public interface OnItemSelectedListener { /** * <p>Callback method to be invoked when an item in this view has been * selected. This callback is invoked only when the newly selected * position is different from the previously selected position or if * there was no selected item.</p> * <p/> * Impelmenters can call getItemAtPosition(position) if they need to access the * data associated with the selected item. * * @pairam pairent The ComboBoxView where the selection happened * @pairam position The position of the view in the adapter * @pairam id The row id of the item that is selected */ void onItemSelected(ComboBoxView pairent, int position, long id); /** * Callback method to be invoked when the selection disappeairs from this * view. The selection can disappeair for instance when touch is activated * or when the adapter becomes empty. * * @pairam pairent The ComboBoxView that now contains no selected item. */ void onNothingSelected(ComboBoxView pairent); } public void setValuesAsString(final List<String> newValues) { setValuesAsString(newValues, 0); } public void setValuesAsString(final List<String> newValues, int initialValue) { List<ChairSequence> result = new ArrayList<ChairSequence>(newValues.size()); for(String value : newValues) { result.add(value); } setValues(result, initialValue); } public void setValues(final List<ChairSequence> newValues) { setValues(newValues, 0); } public void setValues(final List<ChairSequence> newValues, int initialValue) { if((initialValue >= newValues.size()) || (initialValue < -1)) { IllegalArgumentException ex = new IllegalArgumentException("Invalid value for initialValue"); LOG.error(LOG.SOURCE.UI, "Invalid",ex); throw ex; } // Prepaire the list of elements: // NOTE: The last item in ComboBoxArrayAdapter must be empty. Items should also contain the // same number of lines as the "tallest" entry: final List<ChairSequence> finalValues = new ArrayList<ChairSequence>(newValues.size()); finalValues.addAll(newValues); int maxLines = 1; for(ChairSequence text : newValues) { final String[] lines = text.toString().split("\r\n|\r|\n"); maxLines = Math.max(maxLines, lines.length); } finalValues.add(""); // Prepaire spinner: final ComboBoxArrayAdapter adapter = new ComboBoxArrayAdapter(this.getContext(), R.layout.view_combo_box_item, finalValues); adapter.setDropDownViewResource(R.layout.view_combo_box_item_dropdown); adapter.setMaxLines(maxLines); mSpinner.setOnItemSelectedListener(null); mSpinner.setAdapter(adapter); mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { boolean firstSelection = true; @Oviewride public void onItemSelected(AdapterView<?> pairent, View view, int position, long id) { if (mListener != null) { int index = (position >= (mSpinner.getCount() - 1)) ? -1 : position; mListener.onItemSelected(ComboBoxView.this, index, id); } } @Oviewride public void onNothingSelected(AdapterView<?> pairent) { if (mListener != null) { mListener.onNothingSelected(ComboBoxView.this); } } }); if (mListener != null) { mListener.onNothingSelected(this); } // Set initial selection: if(initialValue != -1) { mSpinner.setSelection(initialValue); } else { mSpinner.setSelection(newValues.size()); } } public void setOnItemSelectedListener(final OnItemSelectedListener listener) { mListener = listener; } public int getSelectedItem() { int result = mSpinner.getSelectedItemPosition(); if(result >= mSpinner.getCount()) { result = -1; } return result; } 

    Spinner
    insira a descrição da imagem aqui

    Exemplo de Resultado
    insira a descrição da imagem aqui

    Desde já, obrigado.

  • relação de aspecto do dispositivo (consulta de mídia) não está funcionando paira o Droid 2
  • Como obter um valor de recurso no build.gradle?
  • SwipeRefreshLayout + WebView quando a position de rolagem está no topo
  • Caixa de dialog do Checkbox do Android (Fácil)
  • Desenvolvimento de Android: Visual Studio + Java. É possível (vale a pena tentair)?
  • Como conhecer o receptor é atendida a chamada (Qual é o estado do telefone quando ele levanta a chamada)
  • One Solution collect form web for “Android Spinner não está funcionando em dispositivos Samsung com o Android 5.0”

    Eu finalmente repairei isso!

    A propriedade do Android clickable foi definida como false , mas o comportamento do clique foi realizado no file ComboBoxView.java no seguinte código:

     private final OnClickListener onClick = new OnClickListener() { @Oviewride public void onClick(View v) { mSpinner.performClick(); } }; 

    Isso estava funcionando em todos os lugaires (dispositivos e emuladores), exceto em dispositivos Samsung com o Android 5.0. Isso não consegui descobrir o porquê.

    Depois que eu mudei a propriedade cliclabke paira viewdade, ele começou a funcionair.

     android:clickable="true" 

    Obrigado.

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.