It is useless to say more, and you can directly use the code.
<PRE name = "code" class = "Java"> <span style = "white-space: pre"> </span> class <?> Argclass = msearchview. getclass (); // specify a private attribute field 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 msearchplate is statelistdrawable (images in different States). Therefore, bitmapdrawable field ownfield = argclass cannot be used. getdeclaredfield ("msearchplate"); // setaccessible is used to set whether the private attribute in the reflection class has the permission. It can be accessed only when it is set to true. The default value is false ownfield. setaccessible (true); view mview = (View) ownfield. get (msearchview); mview. setbackground (getresources (). getdrawable (R. drawable. person_edittext_selector ));
<PRE name = "code" class = "Java"> <span style = "white-space: pre"> </span> // modify the close icon field mclosebutton = argclass. getdeclaredfield ("mclosebutton"); mclosebutton. setaccessible (true); imageview backview = (imageview) mclosebutton. get (msearchview); backview. setimageresource (R. drawable. delete_selector); // modify it to the search icon field msearchbutton = argclass. getdeclaredfield ("msearchbutton"); msearchbutton. setaccessibl E (true); imageview search = (imageview) msearchbutton. get (msearchview); search. setimageresource (R. drawable. main_search_selector); // modify the cursor // specify a private attribute field mquerytextview = argclass. getdeclaredfield ("mquerytextview"); mquerytextview. setaccessible (true); Class <?> Mtextviewclass = mquerytextview. get (msearchview ). getclass (). getsuperclass (). getsuperclass (). getsuperclass (); // mcursordrawableres the attribute of the cursor image ID. This attribute is the property of textview. Therefore, the parent class of the autocompletetextview (searchautocomplete) // is used) field mcursordrawableres = mtextviewclass. getdeclaredfield ("mcursordrawableres"); // setaccessible is used to set whether the private attribute in the reflection class has the permission. It can be accessed only when it is set to true. The default value is false MC. Ursordrawableres. setaccessible (true); // note that the cursor of the object (msearchview) holding this attribute (mquerytextview) must be an image rather than a color because the light is marked with two images, // One is the blinking image when the focus is obtained for the first time, and the other is the image with content at the back. If the color is filled, the flickering image will be lost, // color filling will shorten the distance between the text and the optical mark (some letters will be covered by the cursor ). Mcursordrawableres. Set (mquerytextview. Get (msearchview), R. drawable. divider_selector );