Take the font resource under the fonts path in the local assets directory
Public Static Typeface Gettypeface (context context) { "fonts/bod_pstc.ttf"); return Face ;}
Create a new Popwindow
Public StaticPopupwindow Createpopwindow (Context context,intLayoutID) {View View= Layoutinflater. from(context). Inflate (LayoutID,NULL); Popupwindow Pop=NewPopupwindow (view, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONT ENT); Pop.setoutsidetouchable (false);//Click outside to exitPop.setfocusable (true); Pop.setbackgrounddrawable (NewColordrawable (-00000));//it has to be, otherwise the click outside is invalidpop.update (); returnPop;}
Lock the EditText so that it is not clickable for focus. Unlock the edittext to make it clickable to focus.
/** Lock EditText to make it non-clickable focus*/ Public Static voidLockedittext (Edittext...edts) {if(Edts = =NULL)return; for(intI=0; i<edts.length;i++) {Edts[i].setfocusableintouchmode (false); }} /** Unlock edittext so that it can be clicked in focus*/ Public Static voidUnlockedittext (Edittext...edts) {if(Edts = =NULL)return; for(intI=0; i<edts.length;i++) {Edts[i].setfocusableintouchmode (true); }}
Determines whether a string is a number
/** Determine if the string is a digital----1,java function*/ Public Staticboolean isNumeric1 (String str) { for(inti = Str.length ();--i>=0;){ if(!Character.isdigit (Str.charat (i))) { return false; } } return true;} /** Determine if a string is a number----mode 2, Regular expression*/ Public Staticboolean isNumeric2 (String str) {pattern pattern= Pattern.compile ("[0-9]*"); returnpattern.matcher (str). matches (); } /** Determine if the string is a digital----mode 3,ASCII code*/ Public Staticboolean isNumeric3 (String str) { for(intI=str.length ();--i>=0;){ intChr=Str.charat (i); if(chr< -|| Chr> $) return false; } return true;}
Detect if the service is running
Public StaticBoolean isservicerunning (context context, String Serviceclassname) {final Activitymanager Activitymanager=(Activitymanager) Context.getapplicationcontext (). Getsystemservice (Context.activity_service); Final List<RunningServiceInfo> Services =activitymanager.getrunningservices (Integer.max_value); for(Runningserviceinfo runningserviceinfo:services) {if(RunningServiceInfo.service.getClassName (). Equals (Serviceclassname)) {return true; } } return false; }
Determine if IP and port are valid
Public Staticboolean isipaddress (string IP, String port) {Boolean isavaliable=false;//Initial is invalid if(IsNumeric1 (port)) {IP= Ip.replace (" ",""); String[] Substrs= Ip.split ("\\."); if(Substrs.length = =4) for(intI=0;i<4; i++) if(IsNumeric1 (Substrs[i])) {intn =integer.valueof (Substrs[i]); if(N >-1&& N < the) isavaliable =true; } } returnisavaliable;}
A large wave static method