Tag Archives: array

3,602 views

Shuffle array int string Java Android

String [] arOfStrings = {"one", "two", "three"}; List<String> mListOfStrings = new ArrayList<String>(Arrays.asList(arOfStrings)); Collections.shuffle(mListOfstrings); String str = mListOfStrings.get(2);// 2 is index of pozition an element     int [] arOfInt = {1, 2, 3}; List<Integer> mListOfInt = new ArrayList<Integer>(Arrays.asList(arOfInt)); Collections.shuffle(mListOfInt);

Posted in Android Examples Code, Array,List,Collections | Tagged , | Comments Off on Shuffle array int string Java Android
3,859 views

String Array of Array Java Example

Set, get string , array of array of strings, Java example code public final static String[][]_arArOfString_1 = { new String[] {"bla","bla","hello world!"}, new String[] {}, new String[] {}, new String[] {}, new String[] {}, new String[] {} }; String sOut … Continue reading

Posted in Android Examples Code, Array,List,Collections | Tagged , , | Comments Off on String Array of Array Java Example
4,822 views

Shuffle Array of String Java Example

String[] sAr = new String[] {"one","two","three"}; List<String> wordList = Arrays.asList(sAr); Collections.shuffle( wordList); String[]myShuffledArray = wordList.toArray(new String[wordList.size()]);

Posted in Android Examples Code, Array,List,Collections | Tagged | Comments Off on Shuffle Array of String Java Example
3,593 views

Save Restore Array List Android Example

int[] mArrayOfInt; String[] mArrayOfString; List<String> mList; public void saveState(Bundle map) { map.putIntArray("mArrayOfInt", mArrayOfInt); map.putStringArray("mArrayOfString", mArrayOfString); map.putStringArrayList("mList", mList); }   public void restoreState(Bundle map) { mArrayOfInt= map.getIntArray("mArrayOfInt"); mArrayOfString = map.getStringArray("mArrayOfString"); mList = map.getStringArrayList("mList");   }

Posted in Android Examples Code, Array,List,Collections | Tagged , , | Comments Off on Save Restore Array List Android Example
3,193 views

R.string to string R.array to array Android

R.string to string Android source code R.array to string [] Android source code String s = getResources().getString(R.string.my_string); // Hello world!! String[] arrayOfStrings = getResources().getStringArray(R.array.my_array); // one, two <xml version="1.0" encoding="utf-8"> <resources> <string-array name="my_array"> <item>one</item> <item>two</item> </string-array> <string name="my_string">Hello world!!</string> </resources>

Posted in Android Examples Code, Array,List,Collections | Tagged , | Comments Off on R.string to string R.array to array Android
5,789 views

Array copy to Array Java Android example

String[] source = {"Hello","world","by","Android"};   String[] destination = new String[source.length];   System.arraycopy(source, 0, destination, 0, source.length);

Posted in Android Examples Code | Tagged , , , | Comments Off on Array copy to Array Java Android example
12,357 views

On Touch Event MotionEvent onTouchEvent basic Android sample code

boolean onTouchEvent(MotionEvent event) , PointF() private final PointF mPointF = new PointF();   private int mLastWarpX = -9999; // don’t match a touch coordinate private int mLastWarpY;   @Override public boolean onTouchEvent(MotionEvent event) { float[] pt = { event.getX(), event.getY() … Continue reading

Posted in Android Examples Code | Tagged , , , , | Comments Off on On Touch Event MotionEvent onTouchEvent basic Android sample code
4,525 views

Map TreeMap get values to array Java Android example

import java.util.Map; import java.util.TreeMap;   public class MainClass { public static void main(String[] arg) {   // english;germany dictionary String[] arrayOfString = { "one;eine", "two;zwei", "two sets of;zwei" , "three;drei", "four;vier" };   Map<String, String> map = new TreeMap<String, String>(); … Continue reading

Posted in Android Examples Code, Array,List,Collections | Tagged , , , , , | Comments Off on Map TreeMap get values to array Java Android example
5,741 views

Shuffle List ArrayList Collections Java example

Add and shuffle elements in LinkedList or ArrayList Java basic example. import java.util.Collections; import java.util.LinkedList; import java.util.List;   public class MainClass { public static void main(String[] arg) { String[] arrayOfString = {"nothing", "Hello", "people" , "bye-bye", "hello", "world!", "End" }; … Continue reading

Posted in Android Examples Code, Array,List,Collections | Tagged , , , , , | Comments Off on Shuffle List ArrayList Collections Java example
5,363 views

List LinkedList add sort find Item in Java example

List LinkedList Collections add sort find search Item, get searched item to string in Java example. MainClass.java import java.util.Collections; import java.util.LinkedList; import java.util.List;   public class MainClass { public static void main(String[] arg) { String[] arrayOfString = {"nothing", "Hello", "people" … Continue reading

Posted in Android Examples Code, Array,List,Collections | Tagged , , , , , , | Comments Off on List LinkedList add sort find Item in Java example