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.

Hashtable find value by key Java Android example


Hashtable find value by key Java Android basic example.


import java.util.Hashtable;

public class MainClass {
	public static void main(String[] arg) {
		
		// english;germany dictionary
		String[] arrayOfString = { "one;eine", "two;zwei", "three;drei" };

	    Hashtable hashTable = new Hashtable();
	    for(String s: arrayOfString){
	    	String[] array = s.split(";");
	    	String sKey ="", sValue="";
	    	if(array.length > 1){
	    	sKey = array[0]; sValue = array[1];
	    		hashTable.put(sKey, sValue);
	    	}
	    }

       // check if key exists 	    
	   if( hashTable.containsKey("two")){
		System.out.print("two = " + hashTable.get("two"));
	   }
	    
	}
}
/*
two = zwei
 */

397LW NO topic_id



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


169

Iterate HashMap getKey getValue Java Example | iterate-hashmap-getkey-getvalue-java-example



 HashMap<String,Locale> _mapOfLocale = new HashMap<String,Locale>();
    _mapOfLocale.put("French",Locale.	FRENCH	);	
    _mapOfLocale.put("German",Locale.	GERMAN	);	
    _mapOfLocale.put("Italian",Locale.	ITALIAN	);	

    for (Entry<String, Locale> entry : _mapOfLocale.entrySet()) {

       System.out.println(entry.getKey());
       System.out.println(entry.getValue());

      }



381

InterstitialAd Admob not visible | interstitialad-admob-not-visible



// on bottom of onCreate add listener
mInterstitialAd .setAdListener(new AdListener(){
     public void onAdLoaded(){
          interstitial.show();
     }
});

} // end onCreate

 public void displayInterstitial (){
        if (mInterstitialAd.isLoaded()) {
            mInterstitialAd.show();
        }
    }



70

Foreach loop cycle in Java Android example | foreach-loop-cycle-in-java-android-example


Foreach in Java basic example source code.

MainClass.java


public class MainClass {
	public static void main(String[] arg) {
		String[] arrayOfString = { "Hello", "people", "hello", "world!" };

		for (String s : arrayOfString)
			System.out.println(s);

	}
}

385

EditText hint not show | edittext-hint-not-show


Try this solution - into xml file add row to EditText tag:


android:textColorHint="@color/grey"

289

AlertDialog setButton Deprecated | alertdialog-setbutton-deprecated


Solution:

public void alertMy(String sTitle, String sMessage){
	AlertDialog.Builder builder = new AlertDialog.Builder(Test.this); // activity
  builder.setTitle(sTitle)
  .setMessage(sMessage)
  .setCancelable(false)
  .setNegativeButton("Close",new DialogInterface.OnClickListener() {
      public void onClick(DialogInterface dialog, int id) {
          dialog.cancel();
      }
  });
  AlertDialog alert = builder.create();
  alert.show();

}



Editace: 2013-12-09 10:56:31
Počet článků v kategorii: 397
Url:hashtable-find-value-by-key-java-android-example
Share
Share
Tweet