android - EditText setText not working in ActionBar CustomView -


i have custom actionbar search field using edittext following this tutorial. trying settext edittext using string. have tried this, not working:

    actionbar action = getsupportactionbar();     action.setdisplayshowcustomenabled(true);     action.setcustomview(r.layout.search_bar);         edtseach = (edittext) action.getcustomview().findviewbyid(r.id.edtsearch);                 edtseach.settext(tv1); 

i tried experiment using normal edittext, works:

input = (edittext) findviewbyid(r.id.input); input.settext(tv1); 

why settext not working when put under actionbar customview? how work?

i try tutorial code , it's work if want set edittext default value put this.

define variable :

private string tv1 = "google"; 

and use code.

 action.setdisplayshowcustomenabled(true); //enable display             // custom view in action bar.             action.setcustomview(r.layout.search_bar);//add custom view             action.setdisplayshowtitleenabled(false); //hide title              edtseach = (edittext)action.getcustomview().findviewbyid(r.id.edtsearch);               edtseach.settext(tv1); 

it set google in edittext.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -