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
Post a Comment