break statement in Java Android example
break statement in Java Android basic example
MainClass.java
MainClass.java
public class MainClass {
public static void main(String[] arg) {
String[] arrayOfString = {"nothing", "Hello", "people"
, "bye-bye", "hello", "world!", "end" };
for (int i = 0; i < arrayOfString.length; i++) {
System.out.println(arrayOfString[i]);
if(i > 2)
break; // end of loop
}
}
}
/*
nothing
Hello
people
bye-bye
*/
396LW NO topic_id
AD
Další témata ....(Topics)
If I create own folder layout-w320dp with Eclipse Android 4.4
layout was correctly loaded.
If I trying this application on tablet with Android 2.1 application crashed.
layout was correctly loaded.
If I trying this application on tablet with Android 2.1 application crashed.
How setup color coloring highlight highlighting syntax font size and family in Eclipse Java and XML editor Android example
Java editor
xml editor
xml editor double click in Preferences dialog on xml -> Editor -> Syntax coloring
[caption id="attachment_627" align="alignleft" width="297" caption="Eclipse editor syntax color settings"][/caption]
Java editor
- Go to Eclipse menu Window -> Preferences
- Doubleclick on Java
- Double click on Editor
- Select Java, Javadocs or Comments and setup color and font
- Font size and family change from Window->Preferences-> General->Appearance->Colors and Fonts
- Press OK for saving changes
xml editor
xml editor double click in Preferences dialog on xml -> Editor -> Syntax coloring
[caption id="attachment_627" align="alignleft" width="297" caption="Eclipse editor syntax color settings"][/caption]
Eclipse make own color of toolbars, windows, status bar etc.
https://github.com/jeeeyul/eclipse-themes/wiki/Alternative-Install
https://github.com/jeeeyul/eclipse-themes/wiki/Alternative-Install
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;
}
}
drawRect(), Paint, setStroke(), setStyle(), Canvas example source code.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(new SampleView(this));
}
private static class SampleView extends View {
// CONSTRUCTOR
public SampleView(Context context) {
super(context);
setFocusable(true);
}
@Override
protected void onDraw(Canvas canvas) {
canvas.drawColor(Color.CYAN);
Paint p = new Paint();
// smooths
p.setAntiAlias(true);
p.setColor(Color.RED);
p.setStyle(Paint.Style.STROKE);
p.setStrokeWidth(4.5f);
// opacity
//p.setAlpha(0x80); //
//drawRect (float left, float top, float right, float bottom, Paint paint)
canvas.drawRect(10, 10, 30, 30, p);
}
}
}
Editace: 2011-10-04 10:49:22
Počet článků v kategorii: 396
Url:break-statement-in-java-android-example