Ways to change the Alertdialog title Google is currently not available, only through other means
One way is: first in the source code to find a class called Alertcontroller, this class is Alertdialog implementation class, is not public, and then in this class there is a private member variable called Mtitleview, This is the Alertdialog title of the TextView, so as long as you get this member variable instance, you can customize the title of Alertdialog
The method of getting this instance variable is implemented by two-step reflection, as follows:
Alertdialog dialog =(Alertdialog) Getdialog (); Try{Field Malert= Alertdialog.class. Getdeclaredfield ("Malert"); Malert.setaccessible (true); Object Alertcontroller= Malert.Get(Dialog); Field Mtitleview= Alertcontroller.getclass (). Getdeclaredfield ("Mtitleview"); Mtitleview.setaccessible (true); TextView title= (TextView) Mtitleview.Get(Alertcontroller); Title.settextcolor (0xff33b5e5); } Catch(nosuchfieldexception e) {e.printstacktrace (); } Catch(IllegalArgumentException e) {e.printstacktrace (); } Catch(illegalaccessexception e) {e.printstacktrace (); }
Of course there are other ways, such as hiding the title directly, and then customizing a title in the content view and so on.
Android alertdialog change title color, font, etc.