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.

Android Studio gradle file comment same as java comment


// single line
multi line

397LW NO topic_id


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


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,

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

Eclipse quick help

How to make a quick start the android emulator | how-to-make-a-quick-start-the-android-emulator

Very very quick start of Android Emulator from Eclipse.

  1. Go to Eclipse s menu Window -> Android SDK and AVD Manager

  2. Select Virtual devices

  3. Select check box Snapshot: Enabled

  4. Press Edit AVD button.

If will closed Android Emulator all data will saved on disk.
If will reopen Android Emulator, configuration and data will read from disk.

[caption id="attachment_768" align="alignleft" width="300" caption="android-emulator-enable-quick-start"][/caption]

Array copy to Array Java Android example | 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);


Hue saturation, color, colored filtering Bitmap Image Android example | hue-color-colored-filter-bitmap-image-android-example

colored filtering bitmap android

/* Copyright (C) 2011 The Android Open Source Project
public class MainActivity extends Activity {
private ImageView imageView;
private Button button1;
Drawable bitmapOrg;
private final int[] mColors =
{Color.BLUE, Color.GREEN, Color.RED, Color.LTGRAY, Color.MAGENTA, Color.CYAN,
		Color.YELLOW, Color.WHITE};
	protected void onCreate(Bundle savedInstanceState) {
		imageView = (ImageView)findViewById(R.id.imageView1);
		button1 = (Button)findViewById(R.id.button1);

		bitmapOrg = this.getResources().getDrawable(R.drawable.flower_blue);
        button1.setOnClickListener(new OnClickListener() {
            public void onClick(View view) {
                int mColor = (int) Math.floor(Math.random() * mColors.length);
                bitmapOrg.setColorFilter(mColors[mColor], PorterDuff.Mode.MULTIPLY);



Eclipse Log.e println needs a message | eclipse-log-e-println-needs-a-message

Log.e println needs a message error.
E/AndroidRuntime(330): FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{b.paint/b.paint.MainActivity}: java.lang.NullPointerException: println needs a message

Try this code:

		// Error
                String s = null;
		Log.e("bla", s); // !!! error Log.e println needs a message error.
                // OK
		String s = null;
		Log.e("bla", s+""); // OK 

Editace: 2016-03-12 19:38:38
Počet článků v kategorii: 397

11 Share