List List =NewArrayList (Set); SetSet=NewHashSet (list);//However, there is a point where it is possible to lose data in the conversion, especially when converting from list to set because set cannot have duplicate data//and after switching to set, the order of their original list is gone, Public classCSDN { Public Static voidMain (string[] args) {ListNewArraylist(); Collections.addall (list,"Zhao","Long","RI");//FillSetSet=NewHashset(); Set. AddAll
Recently, a new project cannot be started when it is imported and the following error occurs: Conversion to Dalvik format failed with error 1.After google searches, the basic solution provided by the Internet is as follows or similar:1. If you do not modify the android sdk version, use the project clean command to act on a project. (This processing method is only compatible with lower-version projects in th
In our development work, Findviewbyid may be one of the most used functions, but it is particularly annoying that we often need to type-convert the returned view, enter the trouble, the code is ugly, for example, we used to find some child controls in the activity is generally the case:@Overrideprotected void onCreate(Bundle savedinstancestate) { Super.onCreate(savedinstancestate); Setcontentview(R.Layout.Activity_main); //Find child controls TextView TextView = (Text
The conversion of drawable and bitmap is always not converted. Today I found a blog dedicated to conversion. I have reprinted it and hope to help you all in the future.
From: http://www.iteye.com/topic/642128
Android will perform some type conversion when processing a write image resource. Now I have time to sort i
public class Densityutils {/*** Switch from DP unit to PX (pixel) According to the resolution of the phone*/public static int dip2px (context context, float Dpvalue) {Final float scale = context.getresources (). Getdisplaymetrics (). density;return (int) (Dpvalue * scale + 0.5f);}/*** According to the resolution of the phone from PX (pixel) to the unit to become DP*/public static int Px2dip (context context, float Pxvalue) {Final float scale = context.getresources (). Getdisplaymetrics (). densi
added:xmlns:app= "Http://schemas.android.com/apk/res-auto"You must also include the attr file to set the corresponding self-defined attribute:The following is the application of the activity:public class Mainactivity extends Activity implements Onroundspinviewlistener {private Roundspinview rsv_test;@ overrideprotected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview ( R.layout.activity_main); Initview ();} private void Initview () {rsv_test = (Roun
The Android Project uses the Baidu map location Sdk,web End Use is also Baidu map, later found that the interface shows Baidu map is not as good as the gold effect, the web switch to the gold map, the original Baidu map coordinates can be used directly, due to the German and Baidu map coordinate system inconsistency to how to convert it.After the knowledge of the coordinate system, it was found that the coordinate system used by the GCJ02 is "Mars coo
(new string[size]);2. The array is converted into a list. Call the Aslist method of arrays.Aslistpublic static This method also provides a convenient way to create a fixed-length list that is initialized to contain multiple elements:List stooges = arrays.aslist ("Larry", "Moe", "Curly");Parameters:A-an array of supported lists.Return:Specifies the list view of the array.See also:Collection.toarray ()Specific usage:string[] arr = new string[] {"1", "2"};List List = Arrays.aslist (arr);Array->lis
Incorrect parseInt Function Conversion in WebView of Android. Solution: androidwebview
Today, I was troubled by a problem. One page runs well on a browser (whether on a mobile phone or a PC), and a problem occurs through WebView. There are two problems worth computing. Then, through alert, this value is displayed, and it is found that the calculation result is much different from that on the browser. Origi
Conversion between android bitmap and base64 strings
Bitmap images and base64 strings can be converted to each other ~ Since then, my mom no longer has to worry about processing bitmap ~
/**
* Convert bitmap to a base64 string
*
* @ Param bitmap
* @ Return base64 string
*/
Public String bitmaptoString (Bitmap bitmap, int bitmapQuality ){
// Convert Bitmap into a string
String string = null;
ByteArrayOutput
Android supports screen recording and GIF conversion.
In my previous blog post, I learned several screen recording methods for mobile phones to better demonstrate the implementation of the APP, today, we will introduce two methods that are more comfortable for my personal use:
(1) After configuring the adb environment, run the cmd command to save the operation demonstration on the mobile phone interface a
Common Data conversion methods (Summary) for communication between Android and single chip microcomputer ),
Paste the code below
1. Convert GB2312 to Chinese, such as BAFAC2DCB2B7 → carrot, and combine two bytes into one text.
public static String stringToGbk(String string) throws Exception { byte[] bytes = new byte[string.length() / 2]; for (int j = 0; j
2. Convert Chinese characters to
Android will perform some type conversion when processing a write image resource. Now I have time to sort it out:
1. drawable → bitmap
Java code
Public static bitmap drawabletobitmap (drawable ){
Bitmap bitmap = bitmap
. Createbitmap (
Drawable. getintrinsicwidth (),
Drawable. getintrinsicheight (),
Drawable. getopacity ()! = Pixelformat. opaque? Bitmap. config. argb_8888
: Bitmap. conf
In Android, the unit conversion between dip (dp) and px is dip2px dp to px without context algorithm (and to obtain the screen width and height), and androiddip2px
Let's talk a little bit about the Code:
1. dip2px dp to px without context Algorithm
public static int px2dip(int pxValue){final float scale = Resources.getSystem().getDisplayMetrics().density;return (int) (pxValue / scale + 0.5f);}public stat
Like whatListList.add ("Test1");List.add ("Test2");I want to convert the list to {"Key": ["Test1", "Test2"]} in this form.Now I pass Jsonstringer jsonstringer=new Jsonstringer ();Part of the code is omitted. Jsonstringer.key ("key"). Value (list). The last converted JSON "key" is a string of value values used, in the form of {"Key": "[Test1,test2]"}. I do not know how to implement {"Key": ["Test1", "Test2"]} This effect AH. The JSON is made from Android.Jsonobject object=new jsonobject ();Jsonar
; i ) { intv = src[i] 0xFF; String HV=integer.tohexstring (v); if(Hv.length () ) {stringbuilder.append (0); } stringbuilder.append (HV); } returnstringbuilder.tostring (); }4. Convert the hexadecimal byte[] intact to a string and separate each byte with a space, such as byte[]{0x7e,0x80,0x11,0x20}→7e 80 11 20, which can be used for log printing Public StaticStringBuilder Byte2hexstr (byte[] data) { if(Data! =NULL data.length > 0) {StringBuilder StringBuilder=
Public classDensityutil {/*** Switch from DP unit to PX (pixel) According to the resolution of the phone*/ Public Static intDIP2PX (Context context,floatdpvalue) { Final floatScale =context.getresources (). Getdisplaymetrics (). density; return(int) (Dpvalue * scale + 0.5f); } /*** According to the resolution of the phone from PX (pixel) to the unit to become DP*/ Public Static intPx2dip (Context context,floatpxvalue) { Final floatScale =context.getresources ()
Convert a fixed-format date to a timestamp://formatting Local datesNewDate ('2017-11-11 0:0:0')//The result: Sat 00:00:00 gmt+0800 (China Standard Time)//Date converted to local timestampDate.parse (NewDate ('2017-11-11 0:0:0'))//The result is: 1510329600000"Red">//but can't resolve conversions under iOS system Compatible wording://under iOS:Date.parse (NewDate ('2017/11/11 0:0:0'))//compatible wordingDate.parse (NewDate ('2017-11-11 0:0:0'))|| Date.parse (NewDate ('2017/11/11 0:0:0'))//encapsul
Nonsense does not read said, directly to everyone paste code, code with comments, can explain everything, this article is not good, please forgive me.
Import Java.io.ByteArrayOutputStream;
/** * Created by the Administrator on 2016/2/2. *-----------16 binary and string---------*------------solve the Chinese garbled problem---------/public class Stringtosixthutils {private static Stri
ng hexstring = "0123456789abcdef"; * * Encode string into 16 digits, apply to all characters (including Chi
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.