The Labeled continue statement Java example
The Labeled continue statement as goto Java example.
public class MainClass {
public static void main(String[] arg) {
String[] arrayOfString = { "Hello", "people", "hello", "world!" };
OuterLoop: for (int e = 0; e < 4; e++) {
for (int i = 0; i < arrayOfString.length; i++) {
if (arrayOfString[i].equals("hello"))
continue OuterLoop;
System.out.println(arrayOfString[i]);
}
}
}
}
/*
Hello
people
Hello
people
Hello
people
Hello
people
*/
396LW NO topic_id
AD
Další témata ....(Topics)
Activity.java
\res\layout\main.xml
location TouchImageView\src\cz\okhelp\TouchImageView\TouchImageView.java
public class A extends Activity{
Bitmap bm;
TouchImageView touch;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
bm = BitmapFactory.decodeResource(getResources(), R.drawable.chinese_sky_map);
touch = (TouchImageView)findViewById(R.id.myImageView);
touch.setImageBitmap(bm);
}
}
\res\layout\main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="//schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello" />
<cz.okhelp.TouchImageView.TouchImageView
android:id="@+id/myImageView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
location TouchImageView\src\cz\okhelp\TouchImageView\TouchImageView.java
public class TouchImageView extends ImageView {
Context context;
// constructor wihtout using *.xml file
// public TouchImageView(Context context) {
// super(context);
// }
// constructor with xml file
public TouchImageView(Context context, AttributeSet attrs)
{
super(context, attrs);
super.setClickable(true);
this.context = context;
}
}
static boolean mbThemeLight = false;
@Override
public void onCreate(Bundle savedInstanceState) {
if(mbThemeLight)
setTheme(android.R.style.Theme_Light);
super.onCreate(savedInstanceState);
// bla bla bla..........
}
private void switchTheme(){
mbThemeLight = true;
this.recreate();
}
Select file in project explorer
Menu:
File - Make File Read-only - to lock
File - Make File Writable - to unlock

Menu:
File - Make File Read-only - to lock
File - Make File Writable - to unlock

Context context = getApplicationContext();
Drawable drawable = context.getResources().getDrawable(R.drawable.my_image);
// convert drawable to bitmap
Bitmap bitmap = ((BitmapDrawable)drawable).getBitmap();
// convert bitmap to drawable
Drawable d = new BitmapDrawable(bitmap);
Android example source code.
How change background color of View Android sample.
MainActivity.java
main.xml
MainActivity.java
public class MainActivity extends Activity {
TextView hTextView;
TableRow hTableRow;
Button hButton, hButtonStop;
private Handler mHandler = new Handler();
private int nCounter = 0;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
hTextView = (TextView)findViewById(R.id.idTextView);
hButton = (Button)findViewById(R.id.idButton);
hButton.setOnClickListener(mButtonStartListener);
hTableRow = (TableRow)findViewById(R.id.idTableRow1);
} // end onCreate
View.OnClickListener mButtonStartListener = new OnClickListener() {
public void onClick(View v) {
hTableRow.setBackgroundColor(Color.YELLOW);
}
};
}
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="//schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TableLayout android:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/tableLayout1">
<TableRow android:id="@+id/idTableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:background="#5655AA">
<TextView
android:id="@+id/idTextView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
</TableRow>
</TableLayout>
</LinearLayout>
Editace: 2011-10-04 08:58:06
Počet článků v kategorii: 396
Url:the-labeled-continue-statement-java-example