Comments (14)
categorySpinner.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@OverRide
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Log.d("kkkk",""+position);
}
});
setOnItemClickListener Solved My Problem
from betterspinner.
If you create a new List Adapter WITH AN EMPTY LIST the setOnItemSelectedListener will never be called. Add at least one item to the list BEFORE creating the the adapter for it
from betterspinner.
If you take a look at the code, I'm using OnItemClickListener in my code as well, so if you override it, it will break. The solution to your problem is just copy the java file over to you project and modify it as you want. For now, that's all I can think of.
from betterspinner.
Yea I ended up making a composite listener so it doesn't get overridden. I'll push my changes soon
from betterspinner.
Thanks.
from betterspinner.
I'm getting this same issue,
I sew it is unrecommended to use a OnItemClickListener
why not instead change your source code to use OnItemSelectedListener?
it would be helpful for everybody
from betterspinner.
In case of multiple spinners in a single layout, how to get the id of the selected spinner in onItemSelectedListener (parent.getId() always returns -1)
from betterspinner.
Hello,
I am getting same issue. onItemSelected not calling and it is not displaying on the spinner as text,
Find my code below.
ArrayAdapter dataAdapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, products);
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
products_mod.setAdapter(dataAdapter);
products_mod.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@OverRide
public void onItemSelected(AdapterView adapterView, View view, int i, long l) {
Log.d("onItemSelected ",""+i);
}
@OverRide
public void onNothingSelected(AdapterView adapterView) {
}
});
from betterspinner.
@csangeeta try this code its may be help you !
products_mod.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@OverRide
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Log.d("kkkk",""+position);
}
});
from betterspinner.
@thumb2thiefapp setOnItemClickListener cannot be used with spinner, BTW i'm also having the same issue. I've implemented the spinner as stated by the official android documentation. In one of the files of my project it is working as expected but not in the the other files. All the implementations are correctly done as stated by the official documentation in all the files.
from betterspinner.
Thank you @thumb2thiefapp and @gtl23.
from betterspinner.
@csangeeta your welcome !
from betterspinner.
If you create a new List Adapter WITH AN EMPTY LIST the setOnItemSelectedListener will never be called. Add at least one item to the list BEFORE creating the the adapter for it
That solved my issue Thanks
from betterspinner.
This code will help you
ArrayAdapter adapter = new ArrayAdapter(getActivity(), android.R.layout.simple_list_item_1, items);
m_ListView.setAdapter(adapter);
m_ListView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
Log.v("item", (String) parent.getItemAtPosition(position));
Toast.makeText(getActivity(), (String) parent.getItemAtPosition(position), Toast.LENGTH_LONG).show();
Toast.makeText(getActivity(), "working", Toast.LENGTH_LONG).show();
if (position == 1) {
Intent intent = new Intent(getContext(), CategoriesActivity.class);
startActivity(intent);
}
// ((TextView) parent.getChildAt(0)).setTextColor(Color.WHITE);
}
@OverRide
public void onNothingSelected(AdapterView<?> parent) {
// TODO Auto-generated method stub
Log.v("item", (String) parent.getItemAtPosition(0));
}
});
from betterspinner.
Related Issues (20)
- How to change floating label color? HOT 2
- How to set the selected item with particular position? HOT 1
- Please add search popup option.
- Annoying Double Tap issue HOT 3
- how to get value and position of selected item ...? HOT 1
- how to align the drop down icon close to the selected text
- Add an option to hide the dropdown arrow icon HOT 1
- How to change the material better spinner background color
- Please add wiki with explanation of usage MaterialEditText
- How to set typeface in label and hint
- My fix for bugs with empty data, focus, setText and setSelected/getSelected feature
- disable MaterialBetterSpinner HOT 1
- Wrap Long Text
- HOW TO set default value HOT 1
- How to change right icon on betterspinner HOT 1
- how to open spinner programmatically?
- How to validate if no value selected HOT 1
- MaterialBetterSpinner selection remove HOT 1
- Poor docs: Can't get selected item from spinner nulls
- how to know which better spinner is selected or clicked HOT 2
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 betterspinner.