//Specify a private propertyField Msearchhinticonfield = Argclass.getdeclaredfield ("Msearchhinticon"); Msearchhinticonfield.setaccessible (true); ImageView Msearchhinticon= (ImageView) Msearchhinticonfield.Get(Msearchview); //msearchhinticon.setvisibility (View.gone); Msearchhinticon.setimageresource (R.drawable.main_search_selector); //Note that the background of the msearchplate is statelistdrawable (different states of the picture) so you can't use bitmapdrawableField Ownfield = Argclass.getdeclaredfield ("msearchplate"); //setaccessible It is used to set whether there is permission to access private properties in the reflection class, only if set to true to be accessible, default to FalseOwnfield.setaccessible (true); View MView= (View) Ownfield.Get(Msearchview); Mview.setbackground (Getresources (). getdrawable (R.drawable.person_edittext_selector));
Field Mclosebutton = Argclass.getdeclaredfield ("Mclosebutton"); Mclosebutton.setaccessible (true); ImageView Backview= (ImageView) Mclosebutton.Get(Msearchview); Backview.setimageresource (R.drawable.delete_selector); //Search icon when modified to expandField Msearchbutton = Argclass.getdeclaredfield ("Msearchbutton"); Msearchbutton.setaccessible (true); ImageView Search= (ImageView) Msearchbutton.Get(Msearchview); Search.setimageresource (R.drawable.main_search_selector); //Modify Cursor//Specify a private propertyField Mquerytextview = Argclass.getdeclaredfield ("Mquerytextview"); Mquerytextview.setaccessible (true); Class<?> Mtextviewclass = Mquerytextview.Get(Msearchview). GetClass (). Getsuperclass (). Getsuperclass (). Getsuperclass (); //Mcursordrawableres the property of the cursor picture ID is the property of the TextView, so use Mquerytextview (searchautocomplete)//The parent class (EditText) of the parent class (Autocompletetextview) ( TextView)Field mcursordrawableres = Mtextviewclass.getdeclaredfield ("Mcursordrawableres"); //setaccessible It is used to set whether there is permission to access private properties in the reflection class, only if set to true to be accessible, default to FalseMcursordrawableres.setaccessible (true); //Note that the first parameter holding this property (Mquerytextview) of the object (Msearchview) cursor must be a picture cannot be a color because the cursor has two pictures,//One is the first time to get the focus of the flashing picture, a picture behind the content, if filled with color, it will lose the flashing picture,//Color fills shorten the distance between the text and the cursor (some letters will cover a portion of the cursor). Mcursordrawableres.Set(Mquerytextview.Get(Msearchview), r.drawable.divider_selector);
Custom Searchview edit box, search button, delete button, cursor etc.