Questions tagged [android-spinner]

1

votes
2

answer
68

Views

How to populate second spinner from a selected value of first spinner from firebase [duplicate]

This question already has an answer here: What is a NullPointerException, and how do I fix it? 12 answers The java.lang.NullPointerException occurs to many other problems too. Mine was different, because the 2nd Spinner is not getting the value from the 1st spinner. The question What is a NullPoint...
Cybertronian
0

votes
0

answer
6

Views

How to prevent a spinner dropdown menu from closing after clicking an item?

I would like to keep the spinner dropdown menu open after an item has been clicked. Its default behavior is to close when an item has been selected. Instead, I want it to stay open to allow the different items to be clicked multiple times without closing the spinner. private Spinner spinner_simple;...
Erlend K.H.
1

votes
4

answer
2.4k

Views

change Spinner text color

I want to change the default text color in Spinner to any other color. But I have not find the solution yet. All I got a solution through TextView like How to change spinner text size and text color? Is there any other way, direct way for Spinner? Note: Please provide solution for Xamarin. Thank yo...
musigh
1

votes
3

answer
98

Views

How to validate empty text in spinners

For my spinner I have a hidden text and a validation code to display error message if spinner is skipped. While the code works if the spinner is not selected, the error message gets displayed all the time even if I have selected an option in spinner. final int pos = spinner5.getSelectedItemPosition(...
Padma Kotish
1

votes
1

answer
984

Views

Custom spinner android

Question: When setting adapter it hides its custom background I am trying to add custom background to spinner like this, my custom drawable is, Setting adapter like this spinnerReferredBy.adapter = ArrayAdapter(activity,R.layout.custom_spinner_item,referred) Outputs without setting adapter With adap...
Pramod Waghmare
1

votes
1

answer
102

Views

Marquee is not working in spinner custom text xml

here is my layout_item.xml : android:id='@+id/txt' android:layout_width='match_parent' android:layout_height='wrap_content' android:padding='8dp' android:gravity='left' android:background='@drawable/spinner_line_box' android:text='janak' android:ellipsize='marquee' android:marqueeRepeatLimit='marque...
Janku
1

votes
0

answer
242

Views

Spinner dialog background color

I know this question will be a duplicate but , even after going through many suggestions, I still couldn't change the dropdown style for popup diolouge of a spinner. Below is my Spinner xml - You see, I already made popup background color as ff0000 and its still not reflecting so please dont give t...
Pradeep Kumar
1

votes
0

answer
42

Views

How to get my Spinner to show String value from my Integer Array list?

I had to create a spinner with each item a different color. I managed to accomplish this but now instead of the text value showing up with the color that is shown, it's just showing up as blank. I've tried using the txv.setText() but this is not what I want. I want it to use my array list values,...
pyuntae
1

votes
1

answer
269

Views

Android Studio Stopping/Killing Timer with Switch Statement

What I've built is a timer with multiple timer styles, using a spinner so the user can switch quickly between the timer they want to use. My problem is with the switch statement - each timer works fine on its own but when going (example) from the Basic Timer to the Countdown Timer via the spinner,...
rsoderberg
1

votes
2

answer
50

Views

Trying to set the current selection of a spinner using a string instead of an index

I would like to set the selection of a spinner using a string instad of an index. So if I have spinner of red, green and blue, I could set the current selection to blue by using the string 'blue' instad of the index 2. How this can be achieved?
Ted pottel
1

votes
0

answer
163

Views

Android: Model bound Spinner resets to first value in its entry list

I use Androids binding to populate my Spinner and set the selected item in the model. This works fine so far. But when I load a model with previously set Spinner value it gets always set to the first item in the Spinners list. This is the Spinners excerpt from the layout file: And the conversion met...
Niels
1

votes
0

answer
47

Views

How do I populate 3 spinners in a fragment and get selected item in text view?

The 2nd spinner is based on the 1st spinner and the 3rd spinner based on the 2nd spinner. Here I tried but it seems whenever I select the second item, it resets and the 1st item is selected. I am unable to select other options only the first one is selected through out the output. This code is not w...
Nikhil Satalkar
1

votes
0

answer
66

Views

Spinner not displaying Emails

final Spinner emailsList = (Spinner) findViewById(R.id.email_list); ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_dropdown_item_1line, getUserEmails()); emailsList.setAdapter(adapter); public ArrayList getUserEmails() { AccountManager manager = AccountManager.get(this); Acco...
Qamran Rajput
1

votes
0

answer
83

Views

SetSelection is not working in android spinner

I am developing an android filter where I am using multiple spinners, the problem is that when I used to setSelection option it is not showing me correct position. But when I use the same functionality within the button click it shows me right selection. I want to know how can I set selection posit...
Abdul Fatah
1

votes
3

answer
285

Views

How to set background of MaterialBetterSpinner in android?

This is my Design of campaign_create.xml Spinner : @drawable/rounded_white.xml I want to set background of spinner. It is drawable file. i set property android:background='@drawable/rounded_white' but it didn't work. How to set background of spinner?
Unnati Patadia
1

votes
1

answer
42

Views

Keep Android Spinner from dropping list

I have an Android spinner that I would like to disable when there's less than one item in my list. What I mean by that is I would like the title to show up, but I don't want a list to drop down when I click it. I've tried isClickable = false, and isEnabled = false like in many of the posts out there...
Rafa
1

votes
1

answer
59

Views

ListView inside / with spinner

Experts,I been struggling to solve the below issue. Have got code which basically searching the data using edittext to spinner which is working fine. But issue is i am unable to open the spinner to see the inside contents.Used AdapterView.OnItemSelectedListener but no use. Your most welcome to modif...
Leace
1

votes
0

answer
33

Views

Unable to select items from the Spinner in Android Studio

I am new to Android Studio, so I don't know much about the functions. I am using a spinner which allows me to choose from different languages. In my MainActivity class, I have the following code: String lang='eng'; dropdown.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { publi...
Hars
1

votes
2

answer
47

Views

Appearance issue in spinners in Android studio

I put two spinners in the same activity, one for City and the other for Town. When the user chooses a City, the Town spinner should populate with items according to the City that was chosen. My problem is, the color of the background and the text is always different from the first one, however they...
Wessam Alkumait
1

votes
0

answer
83

Views

rotate spinner arrow android

i am trying to rotate spinner arrow when spinner click. i try different solution but not get exact result. i want that rotate arrow from up to down when it select. this is my xml code for spinner. this is in activity. ss=(Spinner)findViewById(R.id.pricespinner); ArrayAdapter spinnerArrayAdapter = n...
1

votes
0

answer
32

Views

Disable spinner from moving to last selected item on dropdown

I have a spinner where I am adding hint at the bottom(not adding to top as getSelectedItemPosition will consider the hint as well) using arrayadapter hiding it from showing on dropdown options. The problem I am facing is, if I make the hint to show for the first time by using setSelection, then drop...
User007
1

votes
0

answer
152

Views

Unable to set height for Android Spinner popup in API 21 and 22

Herewith I used 'spinner' with some styles. To set height of the spinner popup, I used 'List Popup Window'. It's working fine for more Android versions. But API 21 and 22 (Android 5.0 and 5.1) not supported. Below is my code that I found from How to limit the height of Spinner drop down view in Andr...
Nuwan Withanage
1

votes
2

answer
52

Views

Spinner not saving the last selected value

I have a spinner in my android application and the spinner goes to the first item whenever I go to other fragment and come back. All I want is that the spinner should retain the value. Below is how I setup the spinner. private void setupSpinner(){ roundSpinnerMap = new HashMap(); roundSpinnerItems...
M.Shaikh
1

votes
2

answer
151

Views

onItemSelected doesn't work

I m having problems working with Spinner. I have a custom adapter for the Spinner. This is the code : public class CategoriaArrayAdapter extends ArrayAdapter { private Context context; private ArrayList values; public CategoriaArrayAdapter(Context context, int textViewResourceId, ArrayList values) {...
Coeus
1

votes
1

answer
91

Views

Android AppCompatSpinner will not dismiss and onItemSelectedListener not called

I have created a custom adapter for a AppCompatSpinner. the custom adapter is below: class MyAdapter(context: Context, var itemViewRes: Int, var dataSource: List) : ArrayAdapter(context, itemViewRes, dataSource) { override fun getDropDownView(position: Int, convertView: View?, parent: ViewGroup?): V...
j2emanue
1

votes
1

answer
61

Views

Android custom ArrayAdapter rendering Objects in list, not values

I'm trying to bind a custom layout (a LinearLayout containing two TextViews) to a Spinner. I subclassed ArrayAdapter (mostly) correctly. Selecting an item in the Spinner calls getView() correctly, setting the LinearLayout's TextViews' values correctly. The problem is the initial display of the items...
TheDudeDude
1

votes
1

answer
54

Views

How to set spinner selection if every field has key and value pair

I am updating a form in android fragment. In which i have spinner, i want to show default selected value in spinner but it is not working.I have searched a lot but nothing works. In function TruckApi.getTruckCapacity('update_truck'); i have added data to truckCapacityList and it is showing in spinn...
Narmail Sandhu
1

votes
0

answer
127

Views

Spinner in RecyclerView to update item values

How can I update the values in my Dataset from a Spinner selection in a RecyclerView? Should I be using LiveData and Room with notifyItemChange(), data binding, or something simpler? I have a Horseclass and a HorseData class. The number of items is static and the options for the variables are static...
MrG
1

votes
0

answer
90

Views

Center align spinner prompt text

I have an android spinner And a custom adapter attached to it. I manage to center text by passing my own layout in public View getView(int position, View convertView, ViewGroup parent) and public View getDropDownView(final int position, final View convertView, final ViewGroup parent) However it see...
Quillion
1

votes
1

answer
134

Views

Spinner dropdown height first time

I used spinner to make a dropdown of the country flags. But the dropdown height is not right at the first time as the images show, but it correct itself when I start scrolling in the dropdown or close it and open it again. I used custom adapter for the spinner class CustomAdapter(context: AppCompatA...
Andrew Hossam
1

votes
0

answer
62

Views

Spinner in RecyclerView Android

I am working on an app, In which I have a update data activity to modify the previous data. In this, I have created a recycler view. I want to fetch data from firebase database and set the spinner according to the value in the firebase. I am using a adapter for data in the spinner, so when I am tryi...
DevAndro
1

votes
0

answer
80

Views

getting data in spinner from retrofit - the application is crashing when click on item

I am getting data from a URL using Retrofit in Android. The response is getting data successfully, but when I click on item in the spinner the app crashes. Here is my code: public class Home extends Fragment { private Button adv_search; int PLACE_PICKER_REQUEST = 1; ArrayList items = new ArrayList()...
S.H
1

votes
1

answer
51

Views

Change the Text color of Spinner Using Textwatcher

Hi I want to change the Spinner text color using the text watcher.Spinner text should change color based on the character entered in edittext or empty edittext. Tried as below but not working if(charSequence.length() >0 ) { spin_motor_displacement.getViewTreeObserver().addOnGlobalLayoutListener(new...
hari86
1

votes
2

answer
31

Views

Populate Edit Text from spinner

I am working on code where for example the user selects a fabric called FabricA and when he selects it, it needs to populate an edit Text with FabricA price. i have tried to implement it but i cant get the price to show in the edit text. I stored the name and price in two different arrays. Should i...
Mohammed Ismail
1

votes
1

answer
36

Views

Checking which ArrayAdapter Spinner currently uses

I have four ArrayAdapters that uses 4 different arrays adapter1 = new ArrayAdapter(getApplicationContext(), android.R.layout.simple_spinner_item,getResources().getStringArray( R.array.array1) ); adapter2 = new ArrayAdapter(getApplicationContext(), android.R.layout.simple_spinner_item,getResources()....
GremlinShX
1

votes
1

answer
38

Views

How to get Specific id of an object in spinner

{ 'Schools': [ { 'SCHOOLRSN': '1', 'SCHOOLNAME': 'Name1' }, { 'SCHOOLRSN': '11', 'SCHOOLNAME': 'Name2' }, { 'SCHOOLRSN': '10', 'SCHOOLNAME': 'Name3' }, { 'SCHOOLRSN': '9', 'SCHOOLNAME': 'Name4' }, { 'SCHOOLRSN': '21', 'SCHOOLNAME': 'Name5' }] this is my JSON, and I want when I choose a name of a sc...
Prateek Gupta
1

votes
0

answer
165

Views

How to show spinner dropdown full screen?

I want to show spinner full screen..I reached i didnot get proper solution. XML Java ArrayAdapter dataAdapter = new ArrayAdapter(this,android.R.layout.simple_spinner_dropdown_item, categories) { @Override public View getDropDownView(int position, View convertView, ViewGroup parent) { View v = null;...
Gowthaman M
1

votes
0

answer
25

Views

fetch data for spinners from REST APi [cascade]

I have in one activity 6 spinners and at the beginnig to 1st one it fetchs data automatically using rest api and retrofit and the for another spinner i need use value which was selected from 1st spinner and fo the 3d spinner i need get selectedItem from second spinner and so on. i've allready (for f...
1

votes
1

answer
36

Views

custom spinner background is not working on lolipop devices

I have created a custom spinner which works perfectly with all devices except Android 5.0 Here is my code for spinner background This is how it looks other than lolipop devices other than lolipop And on lolipop devices layout.xml I have updated the queastion ..Please check the layout xml
NewBee
1

votes
0

answer
32

Views

spinner value updation by another spinner which uses autocomplete text view not working

I have two spinners in which the first spinner uses autocomplete textview , when first spinner item is selected in normal way without using autocomplete text view the second spinner loads the corresponding value according to the first spinners selection. My issue is that when autocomplete textview...
Kripa_K

View additional questions