Comments (5)
You should just run whatever code is in your listener when you select the item. I don't know why this would be needed. If you really feel like this is necessary please provide an example.
from materialspinner.
spinner.setSelectedIndex(int)
should select that item. Make sure you invoke this method after setting the items in the spinner. For example, if I set the selected index to 1 in the sample, then "Jelly Bean" would be selected instead of "Ice Cream Sandwich".
MaterialSpinner spinner = (MaterialSpinner) findViewById(R.id.spinner);
spinner.setItems("Ice Cream Sandwich", "Jelly Bean", "KitKat", "Lollipop", "Marshmallow");
spinner.setSelectedIndex(1); // <--- Set the item programmatically
spinner.setOnItemSelectedListener(new MaterialSpinner.OnItemSelectedListener<String>() {
@Override public void onItemSelected(MaterialSpinner view, int position, long id, String item) {
Snackbar.make(view, "Clicked " + item, Snackbar.LENGTH_LONG).show();
}
});
spinner.setOnNothingSelectedListener(new MaterialSpinner.OnNothingSelectedListener() {
@Override public void onNothingSelected(MaterialSpinner spinner) {
Snackbar.make(spinner, "Nothing selected", Snackbar.LENGTH_LONG).show();
}
});
from materialspinner.
The method setSelectedIndex just chooses the item to appear as the first item, but I would like to actually select the item as if it would call on onItemSelected.
Thanks again, very nice spinner!
from materialspinner.
what he means is that when he use spinner.setSelectedIndex(1);
,it justchoose the item to appear as the first item,but it didn't execute the selected event.
I have the same problem,please fix that to make this project better.Thanks man.very nice Spinner!
from materialspinner.
+1
from materialspinner.
Related Issues (20)
- I don't want to hide the Adapter HOT 1
- Selected Item shows with .toString() HOT 2
- Spinner only expands below the view. HOT 1
- Spinner Trigger Item
- Add an option to make changes in drop down text alignment
- Update Request ?
- arrow not show HOT 1
- nothing selected
- How to set maximum number of items ?
- Viewpager2 fragment freezes custom spinner widget when returned after swiping HOT 2
- Items not showing on spinner click , after changing spinner visibility from Gone to visible HOT 1
- When I used it in my Presentation, there were no drop-down boxes
- 麻烦修复下这个异常java.lang.IndexOutOfBoundsException: Index: 3, Size: 3 onRestoreInstanceState
- Cannot add two spinner under same layout HOT 1
- DropDown menu doesn't work when change fragment HOT 1
- Inflate Exception
- Do not showing the Spinner Selected item. HOT 1
- MaterialSpinner Hint HOT 1
- Top and bottom offset in the popup list
- Add Background Image
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from materialspinner.