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.

Continue statement Java example


AD MOB

For and continue statement in Java.

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

		for (int i = 0; i < arrayOfString.length; i++){
			if(arrayOfString[i].equals("hello"))
				continue; // skip to for
			System.out.println(arrayOfString[i]);
		}
	}
}
/*
Hello
people
world!
*/

397LW NO topic_id




AD

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


312

Import project Android Eclipse | import-project-android-eclipse


Import a new Android project for example downloaded from internet via Eclipse into project folder.

  1. Right click into projects explorer in Eclipse and select Import

  2. Android

  3. Existing Android Code Into Workspace

  4. Root Directory (select folder of downloaded project)

  5. Check your downloaded project

  6. Check Copy project into Workspace

  7. Finish (press)




387

Error type 3 Activity class does not exist | error-type-3-activity-class-does-not-exist


Try some solution - each individually or all

  1. Check AndroidManifest.xml activity declaration
    <activity
                android:name=".EnableProfileActivity"
                android:label="@string/app_name" />


  2. Delete BUILD folder in module tree and Clean / Rebuild project

  3. Restart Android Studio

165

How to clear or hide an ImageView in Android | how-to-clear-or-hide-an-imageview-in-android



// solution 1
ImageView imageView = (ImageView)findViewById(R.id.myimage);
imageView.setImageDrawable(null);
// or
imageView.setImageResource(0);

// solution 2  hide ImageView
imageView.setVisibility(View.INVISIBLE);

// solution 3 resize ImageView 0, 0
 hImageViewSemafor.setLayoutParams(new LinearLayout.LayoutParams(0,0));
92

How add Android code templates to Eclipse | how-add-android-code-templates-to-eclipse


If you have to type frequently the same code you can create templates which can be activate via autocomplete with Ctrl + Space.

For example lets assume setOnClickListener body.

To create a template for this select the menu Window->Preferences and Open Java -> Editor -> Templates

Create new Android template in Eclipse



Type name of template in Eclipse s editor and pres Ctrl+Space


[caption id="attachment_1114" align="alignleft" width="300" caption="Eclipse-show-template-proposals"]eclipse-show-template-proposals[/caption]


Select your template from intellisense help and press Enter or double click on selected item.


[caption id="attachment_1116" align="alignleft" width="300" caption="Eclipse - select your template"][/caption]



	mIdButtonHome.setOnClickListener(new View.OnClickListener() {
		public void onClick(View v) {
			Intent browserIntent = new Intent(Intent.ACTION_VIEW,
					Uri.parse("//android.okhelp.cz/category/software/"));
			startActivity(browserIntent);
		}
	});






Quick help in Eclipse editor: select keyword and press Ctrl+1

Eclipse quick help
26

Get package name Context-getPackageName Android example | get-package-name-context-getpackagename-android-example


If you often copy your Android project to another you have to using function for obtaining varied information about package.
This code show how get package name in Android application as string:

Context context = getContext(); // this.getContext(); getApplicationContext(); etc.
String sPackName = context.getPackageName();



Editace: 2011-10-04 08:57:55
Počet článků v kategorii: 397
Url:continue-statement-java-example

AD
11 Share
Share
Tweet