at java.util.Arrays$ArrayList.get(Arrays.java:75)
Problem in Android application:
Solution: check code for set and get selection
E/AndroidRuntime(416): FATAL EXCEPTION: main
E/AndroidRuntime(416): java.lang.IndexOutOfBoundsException
E/AndroidRuntime(416): at java.util.Arrays$ArrayList.get(Arrays.java:75)
E/AndroidRuntime(416): at android.widget.ArrayAdapter.getItem(ArrayAdapter.java:298)
E/AndroidRuntime(416): at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:351)
E/AndroidRuntime(416): at android.widget.ArrayAdapter.getView(ArrayAdapter.java:323)
E/AndroidRuntime(416): at android.widget.Spinner.makeAndAddView(Spinner.java:192)
E/AndroidRuntime(416): at android.widget.Spinner.layout(Spinner.java:151)
E/AndroidRuntime(416): at android.widget.Spinner.onLayout(Spinner.java:115)
Solution: check code for set and get selection
// Spinner _spin1 contain only 49 items
// you can set max 48 ( range 0 - 48)
// 50 is IndexOutOfBoundsException
_spin1.setSelection(50);
396LW NO topic_id
AD
Další témata ....(Topics)
Try this:
- check names of drawables (file name must contain only abc...xyz 012...789 _ . in Resources folder ,
names have to start with lower case
MyImage.jpg == problem ,
names with space
my image.jpg == problem,
names with -
my-image.png == problem)
- check duplicate names with other extension ( my_image.jpg - my_image.png makes the problem)
- restart Android Studio
- if problem persist:
- check c:\Users\me\AndroidStudioProjects\myProject\myModule\build\intermediates\res\merged\debug\ drawable folder for corupted names or delete ALL drawable folders
- synk projekt, rebuild projekt
- if problem persist:
- restart Android Studio, wait for complete closure of the Android Studio!
- check names of drawables (file name must contain only abc...xyz 012...789 _ . in Resources folder ,
names have to start with lower case
MyImage.jpg == problem ,
names with space
my image.jpg == problem,
names with -
my-image.png == problem)
- check duplicate names with other extension ( my_image.jpg - my_image.png makes the problem)
- restart Android Studio
- if problem persist:
- check c:\Users\me\AndroidStudioProjects\myProject\myModule\build\intermediates\res\merged\debug\ drawable folder for corupted names or delete ALL drawable folders
- synk projekt, rebuild projekt
- if problem persist:
- restart Android Studio, wait for complete closure of the Android Studio!
If you using GoogleAdMobAdsSdk-4.0.4.jar in your project and set android:targetSdkVersion="17" in AndroidManifest.xml , ads will not visible on emulator with Android 4.0.3 or 4.1.
You have to set as android:targetSdkVersion="17"
Update project.properties file - row with target to 17:
You have to set as android:targetSdkVersion="17"
<uses-sdk android:minSdkVersion="4"
android:targetSdkVersion="17" />
Update project.properties file - row with target to 17:
# Project target.
target=android-17
do while Java example
public class MainClass {
public static void main(String[] arg) {
String[] arrayOfString = { "Hello", "people", "hello", "world!" };
int i = 0;
// first cycle is always executed
do {
System.out.println("Loop: " + i);
System.out.println(arrayOfString[i]);
i++;
}while ( i == -1 );
}
}
/*
Loop: 0
Hello
*/
public class MainClass {
public static void main(String[] arg) {
String[] arrayOfString = { "Hello", "people", "hello", "world!" };
int i = 0;
do {
System.out.println("Loop: " + i);
System.out.println(arrayOfString[i]);
i++;
}while ( i < arrayOfString.length );
}
}
/*
Loop: 0
Hello
Loop: 1
people
Loop: 2
hello
Loop: 3
world!
*/
If a button have focus, marquee will run.
Important:
android:singleLine="true"
android:ellipsize="marquee"
Optional:
android:marqueeRepeatLimit="1"
Important:
android:singleLine="true"
android:ellipsize="marquee"
Optional:
android:marqueeRepeatLimit="1"
// main.xml
<Button
android:layout_width="150dip"
android:layout_height="wrap_content"
android:text="My button with a long text for marquee as a example source code"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="1"/>
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
[caption id="attachment_1114" align="alignleft" width="300" caption="Eclipse-show-template-proposals"]
[/caption]
[caption id="attachment_1116" align="alignleft" width="300" caption="Eclipse - select your template"]
[/caption]
Quick help in Eclipse editor: select keyword and press Ctrl+1

For example lets assume setOnClickListener body.
To create a template for this select the menu Window->Preferences and Open Java -> Editor -> Templates

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"]

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"]

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

Editace: 2014-02-15 20:32:53
Počet článků v kategorii: 396
Url:at-java-util-arraysarraylist-getarrays-java75