goto statement in Java
You can use for, do while, while cycle for example:
public void myFunction(){
for (int i = 0; i < 1; i++) {
// some code
int c = 10;
if(c==10)
break; // goto stop; in C++
} // end of for
// stop: // break moved process to end of for
// next code
}
396LW NO topic_id
AD
Další témata ....(Topics)
Try before html tags put space and check if every tag is closed b - /b.
For example:
"java.lang.IndexOutOfBoundsException
at android.graphics.Paint.getTextRunAdvances(Paint.java:1731)
at android.graphics.Paint.getTextRunAdvances(Paint.java:1704)
at android.text.MeasuredText.addStyleRun(MeasuredText.java:164)
at android.text.MeasuredText.addStyleRun(MeasuredText.java:204)
at android.text.StaticLayout.generate(StaticLayout.java:281)
at android.text.StaticLayout.(StaticLayout.java:140)
at android.text.StaticLayout.(StaticLayout.java:80)
at android.text.StaticLayout.(StaticLayout.java:59)
at android.widget.TextView.makeSingleLayout(TextView.java:5901)
at android.widget.TextView.makeNewLayout(TextView.java:5741)
at android.widget.TextView.onMeasure(TextView.java:6098)
at android.view.View.measure(View.java:15172)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4814)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1390)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:681)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:574)
at android.view.View.measure(View.java:15172)
at android.widget.ListView.setupChild(ListView.java:1847)
at android.widget.ListView.makeAndAddView(ListView.java:1772)
at android.widget.ListView.fillDown(ListView.java:672)
at android.widget.ListView.fillSpecific(ListView.java:1330)
at android.widget.ListView.layoutChildren(ListView.java:1600)
at android.widget.AbsListView.onLayout(AbsListView.java:2102)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4362)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1649)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1507)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1420)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4362)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4362)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1649)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1507)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1420)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4362)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4362)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1866)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1687)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:998)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4212)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
at android.view.Choreographer.doCallbacks(Choreographer.java:555)
at android.view.Choreographer.doFrame(Choreographer.java:525)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
"
For example:
My text (<i>some text</i>) blah blah...
Change to:
My text ( <i>some text</i>) blah blah...
"java.lang.IndexOutOfBoundsException
at android.graphics.Paint.getTextRunAdvances(Paint.java:1731)
at android.graphics.Paint.getTextRunAdvances(Paint.java:1704)
at android.text.MeasuredText.addStyleRun(MeasuredText.java:164)
at android.text.MeasuredText.addStyleRun(MeasuredText.java:204)
at android.text.StaticLayout.generate(StaticLayout.java:281)
at android.text.StaticLayout.
at android.text.StaticLayout.
at android.text.StaticLayout.
at android.widget.TextView.makeSingleLayout(TextView.java:5901)
at android.widget.TextView.makeNewLayout(TextView.java:5741)
at android.widget.TextView.onMeasure(TextView.java:6098)
at android.view.View.measure(View.java:15172)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4814)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1390)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:681)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:574)
at android.view.View.measure(View.java:15172)
at android.widget.ListView.setupChild(ListView.java:1847)
at android.widget.ListView.makeAndAddView(ListView.java:1772)
at android.widget.ListView.fillDown(ListView.java:672)
at android.widget.ListView.fillSpecific(ListView.java:1330)
at android.widget.ListView.layoutChildren(ListView.java:1600)
at android.widget.AbsListView.onLayout(AbsListView.java:2102)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4362)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1649)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1507)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1420)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4362)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4362)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1649)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1507)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1420)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4362)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4362)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1866)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1687)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:998)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4212)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
at android.view.Choreographer.doCallbacks(Choreographer.java:555)
at android.view.Choreographer.doFrame(Choreographer.java:525)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
"
Put your sglite database to Android Eclipse project folder named Assets.
On device will copy database file to application folder as this example:
On device will copy database file to application folder as this example:
public void createDatabase(Context myContext) throws IOException {
String sPackName = myContext.getPackageName();
InputStream assetsDB = myContext.getAssets().open("myDatabase");
OutputStream dbOut = new FileOutputStream("/data/data/"+sPackName+"/database");
byte[] buffer = new byte[1024];
int length;
while ((length = assetsDB.read(buffer))>0){
dbOut.write(buffer, 0, length);
}
dbOut.flush();
dbOut.close();
assetsDB.close();
}
Click Handler Android Java example source code. Open new class as activity and open URL in browser.
In layout.xml file:
In string.xml
In MainClass.java file
In layout.xml file:
android:layout_height="wrap_content" android:onClick="@string/clickHandler">
In string.xml
myClickHandler
In MainClass.java file
public void myClickHandler(View view) {
switch (view.getId()) {
// open new class as activity
case R.id.btnOpenClass: {
Intent pictureActivity = new Intent(getBaseContext(),
MyClass.class);
startActivity(pictureActivity);
}
break;
case R.id.btnAbout: {
//aboutDialogCreate();
}
break;
// open url
case R.id.btnHome: {
String url = "//android.okhelp.cz/";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}break;
}
}// end myClickHandler
// listener .. if click on button will scrolling to mTextView bottom
private OnClickListener mButtonListener = new OnClickListener() {
public void onClick(View v) {
// do something when the button is clicked
int nBottom = mTextView.getBottom();
hScrollView.scrollTo(0, nBottom);
}
};
How to resize an image in ImageView Android source code.
Resize imageview layout and image will resize too:
Resize imageview layout and image will resize too:
public void resizeImageView(int width, int height) {
final ImageView picture1 = (ImageView)findViewById(R.id.imageView1);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(width, height);
picture1.setLayoutParams(layoutParams);
}
Unable to resolve target android-7
Try this solution:
Select project from tree (project explorer)
- right click on project
- properties
- select Android from tree
- change Project Build Target to higher (or change project build target)
- selct from menu: Project-Clean ( select your project - OK)
Try this solution:
Select project from tree (project explorer)
- right click on project
- properties
- select Android from tree
- change Project Build Target to higher (or change project build target)
- selct from menu: Project-Clean ( select your project - OK)
Editace: 2012-12-08 10:02:33
Počet článků v kategorii: 396
Url:goto-statement-in-java