Text color of a closed spinner

To modify the text color create a new xml file in your res/layout folder (for example my_spinner_text.xml). Add a text view to the new xml file and modify how you want: <TextView android:id=”@+id/spinnerText” android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:layout_centerHorizontal=”true” android:textColor=”#CCCCCC” android:textSize=”20dp” xmlns:android=”http://schemas.android.com/apk/res/android”/> Create an ArrayAdapter that uses the new TextView and set it to your spinner: Spinner localSpinner … Read more

How can I use onItemSelected in Android?

You’re almost there. As you can see, the onItemSelected will give you a position parameter, you can use this to retrieve the object from your adapter, as in getItemAtPosition(position). Example: spinner.setOnItemSelectedListener(this); … public void onItemSelected(AdapterView<?> parent, View view, int pos,long id) { Toast.makeText(parent.getContext(), “OnItemSelectedListener : ” + parent.getItemAtPosition(pos).toString(), Toast.LENGTH_SHORT).show(); } This will put a message … Read more

How do I create an Android Spinner as a popup?

You can use an alert dialog AlertDialog.Builder b = new Builder(this); b.setTitle(“Example”); String[] types = {“By Zip”, “By Category”}; b.setItems(types, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); switch(which){ case 0: onZipRequested(); break; case 1: onCategoryRequested(); break; } } }); b.show(); This will close the dialog when one of them is … Read more

Android Spinner – How to make dropdown view transparent?

You can override the style for the dropdown, and the dropdown item by using a Theme in your app that inherits from one of the Android themes, then override the android:dropDownSpinnerStyle, or android:spinnerDropDownItemStyle, and even the android:dropDownListViewStyle attribute of the theme, pointing to your own custom style instead of the Android style that is defined … Read more

Spinner onItemSelected called erroneously (without user action)

Another option in the spirit of Bill Mote’s solution is to make the OnItemSelectedListener also an OnTouchListener. The user interaction flag can then be set to true in the onTouch method and reset in onItemSelected() once the selection change has been handled. I prefer this solution because the user interaction flag is handled exclusively for … Read more

WPF loading spinner

A very simple “plug and play” spinner could be one of the spinning icons from the Font Awesome Wpf Package (Spinning icons). The usage is quite simple, just install the nuget package: PM> Install-Package FontAwesome.WPF Then add the reference to the namespace xmlns:fa=”http://schemas.fontawesome.io/icons/” and use the ImageAwesome control. Set the Spin=”True” property and select one … Read more

How to color and alignment spinner item on android?

Use a custom view for that, and specify by calling: a.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); Note that you have to use your own view here: R.id.my_simple_spinner_dropdown_item <?xml version=”1.0″ encoding=”utf-8″?> <TextView xmlns:android=”http://schemas.android.com/apk/res/android” android:id=”@android:id/text1″ style=”?android:attr/spinnerItemStyle” android:singleLine=”true” android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:ellipsize=”marquee” />