Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android simple spinner item

Tags:

this question relates to this one: android.R.simple_spinner_item

Since I can't comment because of low reputation, I have an additional question:

If I copy&paste the android.R.simple_spinner_item layout, I get an error on

android:layout_height="?android:attr/dropdownListPreferredItemHeight" 

saying "error: Error: Attribute is not public. (at 'layout_height' with value '?android:attr/dropdownListPreferredItemHeight')."

I just added android:gravity="right" to get the spinner_item alignment to the right side.

How can I solve this error?

like image 905
Zuop Avatar asked Sep 26 '14 09:09

Zuop


People also ask

What is spinner in Android with example?

Spinners provide a quick way to select one value from a set. In the default state, a spinner shows its currently selected value. Touching the spinner displays a dropdown menu with all other available values, from which the user can select a new one.

How do you add entries to a spinner?

For adding item in Spinner, you can do one thing, try to create an adapter and then add/remove items into the adapter, then you can easily bind that adapter to spinner by using setAdapter() method.

What is an ArrayAdapter in Android?

ArrayAdapter is the most commonly used adapter in android. When you have a list of single type items which are stored in an array you can use ArrayAdapter. Likewise, if you have a list of phone numbers, names, or cities. ArrayAdapter has a layout with a single TextView.

What is ImageView in Android?

ImageView class is used to display any kind of image resource in the android application either it can be android. graphics. Bitmap or android. graphics. drawable.


1 Answers

Seems to work for me if you don't prefix it with android, like so:

<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"              android:id="@android:id/text1"              style="?android:attr/spinnerDropDownItemStyle"              android:singleLine="true"              android:layout_width="match_parent"              android:layout_height="?attr/dropdownListPreferredItemHeight"              android:ellipsize="marquee"/> 
like image 149
Daniel Wilson Avatar answered Sep 29 '22 18:09

Daniel Wilson