android - setOnEditorActionListener is not called in lollipop -


i want create layout user types in artist name , when presses search on virtual keyboard list of artists displayed.

view rootview = (view) inflater.inflate(r.layout.fragment_search, container, false); edittext searchartist = (edittext) rootview.findviewbyid(r.id.searchartist); searchartist.setoneditoractionlistener(new textview.oneditoractionlistener() {     @override     public boolean oneditoraction(textview v, int actionid, keyevent event) {         if (actionid == editorinfo.ime_action_search) {             maketoast();             return true;         }         return false;     } }); 

here xml

<edittext     android:id="@+id/searchartist"     android:layout_width="fill_parent"     android:layout_height="wrap_content"     android:hint="@string/search_artist"     android:imeoptions="actionsearch"     android:inputtype="text">     <requestfocus /> 

i have searched lot in other stackoverflow post regarding none of solutions seem working.

minsdk 21, testing on nexus 6, compilesdkversion 22, buildtoolsversion '22.0.1'.

also note searchartist(edittext) inside fragment.

more context: listener code inside oncreateview method.

i tested similar code on android 5.1.1. works. suggested insert log message check if oneditoraction being called:

public boolean oneditoraction(textview v, int actionid, keyevent event) {      log.v("tag", "oneditoraction(): " + actionid);        if (actionid == editorinfo.ime_action_search) {          log.v("tag", "oneditoraction(): entered");      ... 

this way, can ensure method being called. editorinfo.ime_action_search constant: 3

i assume maketoast(); method create, right?

just add more information, tested code in fragment. so, don't believe problem code inserted. need ensure listener set before need use it. hope can you

public class mainfragment extends fragment { ....     public view oncreateview(layoutinflater inflater, viewgroup container,         bundle savedinstancestate) {          // view reference whole fragment layout (where searchartist inserted)         view view = inflater.inflate(r.layout.fragment, null);          // find searchartist (there's 1 @id/searchartist inside view)         edittext searchartist = (edittext)view.findviewbyid(r.id.searchartist);          searchartist.setoneditoractionlistener(new  textview.oneditoractionlistener() {         @override         public boolean oneditoraction(textview v, int actionid, keyevent event) {             if (actionid == editorinfo.ime_action_search) {                 log.v("temp", "i'm being clicked " + actionid);                 return true;             }             return false;         }     });     return view;     }// end of oncreateview } // end of fragment 

my xml:

<edittext android:id="@+id/searchartist"      android:layout_width="fill_parent"      android:layout_height="wrap_content"          android:hint="@string/search_artist"          android:imeoptions="actionsearch"        android:inputtype="text" /> 

Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -