Reputation: 17
Is there a way to get the item position on Spinner Object by only focusing and not by OnItemSelected in Android?
Cause i need to add/increment an item when everytime the last item of spinner is focus..
Upvotes: 0
Views: 89
Reputation: 983
Try this.It is working fine.
@Override
public void onItemSelected(final AdapterView<?> parent, View view,
final int position, long id) {
parent.post(new Runnable() {
@Override
public void run() {
spinner.requestFocusFromTouch();
long pos = spinner.getItemIdAtPosition(position+1);
Toast.makeText(getApplicationContext(), "Position : " +pos, Toast.LENGTH_SHORT).show();
}
});
}
Upvotes: 2