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.

Include xml into another xml Android Example


How include layout defined in other xml file into another xml file example:
res/layout/my_layout.xml into
main.xml

<include  layout="@layout/my_layout" android:id="@+id/idMyLayout" />

397LW NO topic_id



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


307

How to set different locales in android | how-to-set-different-locales-in-android


- create new folder with values in resources folder in project with extension your language code
For example:
My language is Czech (cs)
I have to create the folder values-cs in res folder

// for locale English is default
/MyProject/res/values 
<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="app_name">App English default</string>
    <string name="action_settings">Settings English default</string>
    <string name="hello_world">Hello world</string>

</resources>

// for locale Czech (cs)
/MyProject/res/values-cs
<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="app_name">Aplikace česky cs</string>
    <string name="action_settings">Nastavení česky</string>
    <string name="hello_world">Ahoj světe!</string>

</resources>

// for locale English US (r is region)
/MyProject/res/values-en-rUS

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="app_name">App English Us locale</string>
    <string name="action_settings">Settings English Us locale</string>
    <string name="hello_world">Hello world from USA :)</string>

</resources>


Into every values folder put strings.xml file
Translate every string from values folder into your locale.
If user selected your locale in device settings, application selects a string from the correct (proper) folder.
158

Check Internet connection Android example | check-internet-connection-android-example



public boolean isConnected() {
	 try {
		ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
		 return cm.getActiveNetworkInfo().isConnectedOrConnecting();
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
		Log.e("isConnected", e.getMessage());
		Toast.makeText(getApplicationContext(), e.getMessage(),
				Toast.LENGTH_LONG).show();
		return false;
	}


82

Switch Statement Java basic example | switch-statement-java-basic-example


Switch statement with numbers and array of strings Java example.


public class MainClass {
	public static void main(String[] arg) {
		String[] arrayOfString = { "One", "Two", "Three", "Four" };

		int i = 2;
		switch (i) {
			case 1: {
				System.out.println(arrayOfString[i]);
				break;
			}
			case 2: {
				System.out.println(arrayOfString[i]);
				break;
			}
			case 3: {
				System.out.println(arrayOfString[i]);
				break;
			}
			default: {
				System.out.println("Enter a valid value.");
			}
		} // END of switch
	}
}
/*
 * Three
 */




Possible:

case 1:
 System.out.println(arrayOfString[i]);
break;

// i love this notation 
case 1:{
 System.out.println(arrayOfString[i]);
}break;

case 1:{
 System.out.println(arrayOfString[i]);
 break;
}

311

Where Eclipse stored Settings and Templates Java Code | where-eclipse-stored-templates-java-code



C:\documents\workspace\.metadata\.plugins\org.eclipse.core.runtime\.settings\org.eclipse.jdt.ui.prefs
265

Eclipse failed to create the java virtual machine - Android | eclipse-failed-to-create-the-java-virtual-machine-android


Eclipse: failed to create the java virtual machine - message box

  1. Open folder with Eclipse.exe and find eclipse.ini file

  2. Replace -vmargs
    by your current real path of javaw.exe:
    -vm "c:\Program Files\Java\jdk1.7.0_07\bin\javaw.exe"




-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.200.v20120522-1813
-product
com.android.ide.eclipse.adt.package.product
--launcher.XXMaxPermSize
256M
-showsplash
com.android.ide.eclipse.adt.package.product
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vm "c:\Program Files\Java\jdk1.7.0_07\bin\javaw.exe” 
-Dosgi.requiredJavaVersion=1.6
-Xms40m
-Xmx768m
-Declipse.buildId=v21.1.0-569685


Editace: 2013-01-06 10:41:45
Počet článků v kategorii: 397
Url:include-xml-into-another-xml-android-example
Share
Share
Tweet