android - Converting Integer To Hex Java -
I need this fancy [] format for my app as I wrote in the headline.
The value is derived from a I tried to "convert" it through "for-loop": but I can not convert from Then I tried to change it directly in the XML file, but then my app crashed with NPE. Now I want to know that there is a solution to my problem. Edit: I tried to do it first, but it does not work: Then I tried one of the answers and added for Now it works before returning ... but I do not know why this works: ( There is no form of any typed language int / number values, as in the form of a byte number of Java store int value 4, the use of two supplement Therefore, 0 or 0x0 or 00 (Octagon) or 0b is the same value: 32 in the binary word zero. Second Editing: I think you have a higher-engineered What should you use Then, if you map.get (Key), you will get what you are looking for. New problem: The last solution worked because the values that you read in XML are stored as a decimal: < / P> hashm which is filled with an XML file with this format [00 00 00 00, but I can call every
Int is needed in front of
0x
for
(int i = 0; i & lt; value.length ; I ++) {value [i] = "0x" + value [i]; }
string to
int this way.
Public int [] getValue (map map, string key) {map keyMap = map; Int [] value = {}; @SuppressWarnings ("Raw Type") Iterator IARR = Childmap. Enterreset () Iterator (); While (iter.hasNext ()) {@SuppressWarnings ("Rootsps") map. Entry Mientre = (map.entry) iter.next (); If (mEntry.getKey (.) Equals (key)) {value = (int []) mEntry.getValue (); } } return value; }
(int i = 0; i
map & lt; string, int []> map;
string s = "80"; int i = integer.valueOf (s); // it is equal to 80 (decimal value) int value = Integer.valueOf (String.valueOf (i), 16) ; // it stores 128, or 0x80 (hex value)
Comments
Post a Comment