android - SearchView edittext is always null -
i textview null when doing this:
public boolean oncreateoptionsmenu(menu menu) { getmenuinflater().inflate(r.menu.main, menu); menuitem searchitem = menu.finditem(r.id.action_search); searchview searchview = (searchview) menuitemcompat .getactionview(searchitem); int id = searchview.getcontext().getresources().getidentifier("android:id/search_src_text", null, null); textview textview = (textview) searchview.findviewbyid(id); textview.settextcolor(color.white); }
anyone know why?
i'm using action bar of appcompat v7 , solusion is:
textview searchtext = (textview) searchview.findviewbyid(android.support.v7.appcompat.r.id.search_src_text);
hope help.
Comments
Post a Comment