Okhelp.cz

Recepty, články, nápady, programování. Dříve dum-zahrada, finance, internet a know-how.okhelp.cz Pro lepší výsledky hledání používejte i diakritiku.

ArrayList Collections Add new Item Sort Find Item Java example

How add item to ArrayList, sort ArrayList, search find index of item in ArrayList, min(), max() Java basic example.

import java.util.ArrayList;
import java.util.Collections;

public class MainClass {
	public static void main(String[] arg) {
		String[] arrayOfString = {"nothing", "Hello", "people"
				, "bye-bye", "hello", "world!", "End" };
		   ArrayList<String> arrayList = new ArrayList<String>();
            for(String s: arrayOfString)
		     arrayList.add(s);

		    Collections.sort(arrayList);
		    // foreach
		    for (String str: arrayList)
		      System.out.println(str);
		    
		    Object objMin = Collections.min(arrayList);
		    System.out.println("Min is: " + objMin);
		    
		    Object objMax = Collections.max(arrayList);
		    System.out.println("Max is: " + objMax);
		    
		    int index = Collections.binarySearch(arrayList, "people");
		    System.out.println("Index of people is: " + index);
		    
		  }

		
	
}
/*
End
Hello
bye-bye
hello
nothing
people
world!
Min is: End
Max is: world!
Index of people is: 5
*/

396LW NO topic_id




AD

Další témata ....(Topics)


161

Append text and ad text to TextView Android example | append-text-and-ad-text-to-textview-android-example



String s = "Some text for appending

"; TextView mTitle = (TextView) findViewById(R.id.title_text); mTitle.setText(R.string.app_name); // insert text from strings.xml mTitle.append(s); // append string like a variable value mTitle.append("My string will appended
"); // append string

You can insert this source code into onCreate in your activity file
192

Samsung Galaxy S III - Android | samsung-galaxy-s-iii-android


Špičkový smartphone od Samsungu.

Technické parametry Samsung i9300 Galaxy S III
Rozměry a hmotnost: 137 x 71 x 9 mm, 133 gramů
Datové funkce: GPS modul, WiFi, Bluetooth, NFC, GPRS, EDGE, HSCSD, Hardwarový modem, Infraport
Sítě: pásma GSM 850, 900, 1 800, 1 900 MHz pásma WCDMA (3G) 850, 900, 1 900, 2 100 MHz
Displej: HD Super AMOLED diplej o velikosti 1280x720 4,8 palců
Procesor: čtyřjádrový procesor 1.4 GHz
Uživatelská paměť: 16 MB
paměť RAM 1 024 MB
Operační systém: Android 4.0 ICS
Hudba: MP3
Video: HD rozlišení
Fotoaparát: 8 Mpix
Navigace:
Baterie: Li-Pol, pohotovostní doba 390 hodin
Cena: cca 14.500 korun / léto 2012

Samsung i9300 Galaxy S III obrázek
android/samsung-i9300-galaxy-s-III.jpg
252

Play Sound Android Example | play-sound-android-example



import android.content.Context;
import android.media.AudioManager;
import android.media.SoundPool;

public class SoundManager
{
  private SoundPool soundPool;
  private int[] sm;
  Context context;

  public SoundManager(Context context) {
    this.context = context;
    soundPool = new SoundPool(4, AudioManager.STREAM_MUSIC, 0);
    sm = new int[2];
    // fill your sounds
    sm[0] = soundPool.load(context, R.raw.my_sound1, 1);
    sm[1] = soundPool.load(context, R.raw.my_sound2, 1);
  }

  public final void playSound(int sound) {
      AudioManager mgr = (AudioManager)context.getSystemService(
          Context.AUDIO_SERVICE);  
      float streamVolumeCurrent =
          mgr.getStreamVolume(AudioManager.STREAM_MUSIC);
      float streamVolumeMax = mgr.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
      float volume = streamVolumeCurrent / streamVolumeMax;
      soundPool.play(sm[sound], volume, volume, 1, 0, 1f);
  }

  public final void cleanUpIfEnd() {
    sm = null;
    context = null;
    soundPool.release();
    soundPool = null;
  }
}
120

Statistics usability of mobile phones with Android – October 2011 | statistics-usability-of-mobile-phones-with-android-%e2%80%93-october-2011


Table of usability phones with Android: (Our software)












October 2011 September 2011












Samsung Galaxy S2 10,90%
Samsung Galaxy S 8,10%
Samsung Galaxy Tab 7,00%
Samsung Galaxy Mini 6,20%
HTC Desire HD 4,10%
Samsung Galaxy Ace 4,10%
Samsung Galaxy S 4,00%
Samsung Galaxy Fit 3,30%
HTC Wildfire 3,20%
SEMC Xperia X10 2,20%

























Samsung Galaxy S213.8%
Samsung Galaxy S8.5%
Samsung Galaxy Tab7.4%
Samsung Galaxy Mini5.4%
Samsung Galaxy S4.0%
HTC Desire HD3.8%
Samsung Galaxy Ace3.8%
HTC Wildfire3.2%
Samsung Galaxy Fit3.1%
SEMC Xperia X102.1%



Graph of usability Smartphone with Android - October 2011:
android/phones-usability-wiht-android-october-2011.png


Samsung Galaxy S2 vs iPhone4 - video


Samsung Galaxy S2 vs iPhone4 - browsing, gaming, apps, performance, browser, fast, against, navigation, Sygic, apk, Android, iOS