Android Spinner OnLongClickListener or OnItemLongClickListener -


anyone have work around set up? have spinner in action bar i'd capture long click event, either onlongclicklistener, or individual item onitemlongclicklistener - user can edit value.

i've read spinner doesn't support long clicks, hoping might have changed/someone might have workaround.

it's ideal solution editing string - there's not enough space in action bar put dedicated button editing, , users intuitively try long press edit.

here related questions (although quite old now): android spinner item long click/touch, how can use spinner setonitemlongclicklistener

you should able "simulate" long click following code:

final handler actionhandler = new handler();         final runnable runnable = new runnable() {             @override             public void run() {                 toast.maketext(activity.this, "long click performed", toast.length_short).show();             }         };          spinner.setontouchlistener(new view.ontouchlistener() {             @override             public boolean ontouch(view v, motionevent event) {                 if (event.getaction() == motionevent.action_down) {                     actionhandler.postdelayed(runnable, 1000);                 } else if(event.getaction() == motionevent.action_up){                     actionhandler.removecallbacks(runnable);                 }                 return false;              }         }); 

yo can play around time in order more "real" feeling, that's pretty believe.

i hope helps


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -