Foreach loop cycle in Java Android example
Foreach in Java basic example source code.
MainClass.java
MainClass.java
public class MainClass {
public static void main(String[] arg) {
String[] arrayOfString = { "Hello", "people", "hello", "world!" };
for (String s : arrayOfString)
System.out.println(s);
}
}
396LW NO topic_id
AD
Další témata ....(Topics)
Not request focus EditText if startup Android - hide keyboard if startup.
Remove: from EditText
Create a LinearLayout and set the:
attributes android:focusable="true" android:focusableInTouchMode="true"
Remove:
Create a LinearLayout and set the:
attributes android:focusable="true" android:focusableInTouchMode="true"
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical" >
</LinearLayout>
Try two way in Eclipse IDE:
1.) Import the library project into your Eclipse workspace.
Click File > Import,
select Android > Existing Android Code into Workspace, and browse to the copy of the library project to import it.
If project not visible with checkbox try next step as see below.
2.) Click
File > New > Other
select Android > Existing Android Code into Workspace, and browse to the copy of the library project to import it.
1.) Import the library project into your Eclipse workspace.
Click File > Import,
select Android > Existing Android Code into Workspace, and browse to the copy of the library project to import it.
If project not visible with checkbox try next step as see below.
2.) Click
File > New > Other
select Android > Existing Android Code into Workspace, and browse to the copy of the library project to import it.
How to quickly change all icon set in .apk project with Eclipse:
Right click on project in folder tree
Select New - Ohter
In open wizard dialog select Android Icon Set
Set Icon set name:
Open some large icon for your project for example 512x512 px and wizard will make all set of icons from one largest icon:
Wizard will create all set of icons from this one largest icon.
Click on finish button:
Right click on project in folder tree
Select New - Ohter
In open wizard dialog select Android Icon Set
Set Icon set name:
Open some large icon for your project for example 512x512 px and wizard will make all set of icons from one largest icon:
Wizard will create all set of icons from this one largest icon.
Click on finish button:
Add and shuffle elements in LinkedList or ArrayList Java basic example.
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
public class MainClass {
public static void main(String[] arg) {
String[] arrayOfString = {"nothing", "Hello", "people"
, "bye-bye", "hello", "world!", "End" };
List<String> arrayList = new LinkedList<String>();
for(String s: arrayOfString)
arrayList.add(s);
Collections.shuffle(arrayList);
System.out.println(arrayList);
}
}
/*
[hello, world!, bye-bye, nothing, people, End, Hello]
*/
Download image file from URL to ImageView Java Android source example code.
Context context = thisClass.this;
Drawable image = ImageOperations(context,
"//www.okhelp.cz/images/android/ad_4.png"
,"image.jpg");
ImageView imgView;
imgView = (ImageView)findViewById(R.id.idImageView);
imgView.setImageDrawable(image);
private Drawable ImageOperations(Context ctx, String url, String saveFilename) {
try {
InputStream is = (InputStream) this.fetch(url);
Drawable d = Drawable.createFromStream(is, "src");
return d;
} catch (MalformedURLException e) {
e.printStackTrace();
return null;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
public Object fetch(String address) throws MalformedURLException,IOException {
URL url = new URL(address);
Object content = url.getContent();
return content;
}
Editace: 2011-10-04 08:56:58
Počet článků v kategorii: 396
Url:foreach-loop-cycle-in-java-android-example