int java android example
int occupy 4 bytes (32 bits) in memory
int in Java example of using Integer and Array of Integer and Iteger to String
int in Java example of using Integer and Array of Integer and Iteger to String
// get max end min values of int in Java example 4 bytes (32 bits) PC architecture
System.out.println(Integer.MAX_VALUE); // 2147483647
System.out.println(Integer.MIN_VALUE); // -2147483648
// members variable
private int mProgress = 10;
//integer to string java
int myInteger = 8;
String myString = Integer.toString(myInteger);
// a final variable can only be initialized once
static final int NUM_PARTICLES = 15;
for (int i = 0; i < NUM_PARTICLES ; i++) {
// do something
}
// int as return value of function
public int getCount() {
return 5;
}
// int as a parametr of function
public float getFloatFromInt(int i) {
float fRet = (float) i;
return fRet;
}
//array of int
int[] anArray; // declares an array of integers
anArray = new int[2]; // allocates memory for 2 integers
anArray[0] = 100; // initialize first element
anArray[1] = 200; // initialize second element
for (int i = 0; i < anArray.length; i++) {
// print out values from anArray
System.out.println("Index: " + i);
System.out.println("Value: " + anArray[i]);
}
396LW NO topic_id
AD
Další témata ....(Topics)
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
- File->Project Structure Ctrl + Alt + Shift + S
- Select module and Dependencies Tab
- Click on + PLUS button (right upper corner)
- Select library
Click OK, OK
Terms Screen size, density, density independent pixel, resolution as a picture - pictogram.
Test your knowledge
Q: How to find out the phone screen size?
A: (By length of display diagonale in inch - Not to measure a diagonal of device!!!)
Q: What resolution has 720 x 1280 display?
A: (921600 pixels)
Q: What does it mean "240 dpi" screen density?
A: (Display have density 240 x 240 dots - "Tri-color LED etc." - per every physical (real) square inch. If you have icon 240x240 pixels, this will just occupy an area of one square inch on the display.)
Q: Phone have screen density 240 dpi. Image for 160 dpi screen density have size 128x 128 pixels. What will be the size of the image for 240 dpi screen density?
A: (Calculate the virtual pixels size. 128 * (240/160) = 192. You have to resize image to new size 192 x 192 physical pixels and put into folder drawable-hdpi (high) ~240dpi for phone with screen density 240 dpi. ) or use density independend pixels 128dp x 128dp.
Test your knowledge
Q: How to find out the phone screen size?
A: (By length of display diagonale in inch - Not to measure a diagonal of device!!!)
Q: What resolution has 720 x 1280 display?
A: (921600 pixels)
Q: What does it mean "240 dpi" screen density?
A: (Display have density 240 x 240 dots - "Tri-color LED etc." - per every physical (real) square inch. If you have icon 240x240 pixels, this will just occupy an area of one square inch on the display.)
Q: Phone have screen density 240 dpi. Image for 160 dpi screen density have size 128x 128 pixels. What will be the size of the image for 240 dpi screen density?
A: (Calculate the virtual pixels size. 128 * (240/160) = 192. You have to resize image to new size 192 x 192 physical pixels and put into folder drawable-hdpi (high) ~240dpi for phone with screen density 240 dpi. ) or use density independend pixels 128dp x 128dp.
Sqlite3 create database and table with load.bat file and fill data to table example.
- Create folder for your project: my_sqlite_project
- Open folder and create file load.bat and paste to load.bat this text and save to project folder:
sqlite3 my_database.s3db < load_text.sql
pause
- Create load_text.sql file and paste this text and save to project folder:
CREATE TABLE [android_metadata] (
[locale] TEXT
);
CREATE TABLE [my_table] (
[_id] int NULL,
[word] VARCHAR(255) NULL,
[description] VARCHAR(255) NULL
.separator ";"
.import text_file.txt my_table
- Create text_file.txt and paste this text and save it as UTF-8:
1;word1;my first word
2;word2; my second word - Download sqlite3.exe and put to project folder.
- Run BAT file load.bat and read text instruction from console
- If database created you can open and edit this with sqlite database explorer
- Copy database to Asses Android project folder
- If you want using this database in Android application on device, you have to copy this database to folder on device /data/data/com.MyPackage/databases/
HashMap<String,Locale> _mapOfLocale = new HashMap<String,Locale>();
_mapOfLocale.put("French",Locale. FRENCH );
_mapOfLocale.put("German",Locale. GERMAN );
_mapOfLocale.put("Italian",Locale. ITALIAN );
for (Entry<String, Locale> entry : _mapOfLocale.entrySet()) {
System.out.println(entry.getKey());
System.out.println(entry.getValue());
}
Editace: 2011-09-26 20:51:00
Počet článků v kategorii: 396
Url:int-java-android-example