do while cycle Java basic example
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!
*/
396LW NO topic_id
AD
Další témata ....(Topics)
First: AdView is in XML file
Second: Using AdView in Fragment with LinearLayout
Resolve error in ADT Graphical layout editor:
The following classes could not be instantiated:
- com.google.android.gms.ads.AdView
More about:
https://developers.google.com/mobile-ads-sdk/docs/admob/android/play-migration?hl=it
<com.google.android.gms.ads.AdView
xmlns:ads="//schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adUnitId="MY_AD_UNIT_ID"
ads:adSize="BANNER"/>
// onResume
AdView adView = (AdView)this.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("TEST_DEVICE_ID")
.build();
adView.loadAd(adRequest);
Second: Using AdView in Fragment with LinearLayout
Resolve error in ADT Graphical layout editor:
The following classes could not be instantiated:
- com.google.android.gms.ads.AdView
// layout in xml file
<LinearLayout
android:id="@+id/layout"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
// java class with fragment in Fragment class or in Activity class
private static AdView adView;
@Override
public void onResume(){
super.onResume();
try {
// in xml is empty layout
adView = new AdView(getActivity());
adView.setAdUnitId("ca-app-pub-626/638103xxxxxxx");
adView.setAdSize(AdSize.BANNER);
LinearLayout layout = (LinearLayout)getView() .findViewById(R.id.layout);
layout.addView(adView);
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
More about:
https://developers.google.com/mobile-ads-sdk/docs/admob/android/play-migration?hl=it
Why the app selects data from basic layout folder if smallest width is higher then the number in folder name?
Example 1
layout-sw600dp values-sw600dp (smallest width sw for data usage from this folder is 600dp density independent pixel!!!!!)
Device screen resolution is 1200 x 900 px (pixel) Wow, app to be select data from sw600dp folder! Realy?
DPI of device screen - dot per inch (pixel per inch) is 480 pixel it is wery important number!
In our case smallest dimension of screen must be at least 1800 real - physical pixels (1800 px / 3 ratio(dpi/160) = 600 dp (dip density independend pixels) to be used data from folders values-sw600dp and layout-sw600dp.
Example 2 see Example 1 abouve
Device: Nexus 7 (2012) selected from Android Studio tool layout editor
Resolution: 800x1280 px
DPI: tvdpi (approximately 213dpi)
Ratio: 1.33 (213 / 160)
Smallest width in px: 800
Convert px to dp: 601.5 (800 / 1.33)
Result:Smallest width is 601.5dp The App to be used data from folders values-sw600dp and layout-sw600dp.
Example 1
layout-sw600dp values-sw600dp (smallest width sw for data usage from this folder is 600dp density independent pixel!!!!!)
Device screen resolution is 1200 x 900 px (pixel) Wow, app to be select data from sw600dp folder! Realy?
DPI of device screen - dot per inch (pixel per inch) is 480 pixel it is wery important number!
- App selects smallest dimension of screen. In our case 900 px
Medium screen have 160 dpi (The density-independent pixel is equivalent to one physical pixel on a 160 dpi screen, which is the baseline density assumed by the system for a "medium" density screen.). - App calculate ratio 480 / 160 = 3 (The conversion of dp units to screen pixels: px = dp * (dpi / 160))
- App calculate smallest dimesnion of screen in dp 900 / 3 = 300 dip or dp (density independed pixel).
- App selects data from basic values and layout folder because sw600dp is greater than 300dp.
In our case smallest dimension of screen must be at least 1800 real - physical pixels (1800 px / 3 ratio(dpi/160) = 600 dp (dip density independend pixels) to be used data from folders values-sw600dp and layout-sw600dp.
Example 2 see Example 1 abouve
Device: Nexus 7 (2012) selected from Android Studio tool layout editor
Resolution: 800x1280 px
DPI: tvdpi (approximately 213dpi)
Ratio: 1.33 (213 / 160)
Smallest width in px: 800
Convert px to dp: 601.5 (800 / 1.33)
Result:Smallest width is 601.5dp The App to be used data from folders values-sw600dp and layout-sw600dp.
choreographer skipped frames
Create filter with TAG regex to disable Choreographer messages, see code and picture below:
Create filter with TAG regex to disable Choreographer messages, see code and picture below:
^((?!Choreographer).)*$
Nejlepší Smartphone jaro 2012.
Pdf file
Video - záznam a kvalita videa HTC One S
**VIDEO YOUTUBE
Brand | HTC |
---|---|
Model (codename) | One S |
Price - (Cena, včetně DPH) | 13000 |
Display size in Inch (v palcích) | 4.3 |
Display-resolution (rozlišení) | 960x540 |
Dotek-typ | multi-touch capacitive |
CPU typ | MSM8260A |
CPU MHz | 1500 |
CPU core | 2 |
L2 cache | |
ROM | 16 GB |
RAM | 1 GB |
GPU | Adreno 225 |
NenaMark2 Benchmark | |
GPU-GLBenchmark | |
Battery mAh | 1650 mAh, 10.5 hours of talk time and 13.2 days of stand-by time |
Foto MPx | 8 |
Autofocus | AF |
Video | HD záznam videa, 1920×1080 (1080p HD) @ 30 frame/s - 3GP, .3G2, MP4, WMV, AVI |
Official Android ICS | Android 4.0 Ice Cream Sandwich, HTC Sense 4.0 overlay |
CyanogenMod support | |
Dotek-prstů-max | |
Display-ppi | |
Display-retina | |
Network | HSPA/WCDMA: • Europe/Asia: 850/900/2100 MHz GSM/GPRS/EDGE: • 850/900/1800/1900 MHz |
Connectivity | 3.5 mm stereo audio jack Bluetooth with aptX™ enabled (Bluetooth® 4.0) Wi-Fi®: IEEE 802.11b/g/n DLNA® for wirelessly streaming media from the phone to a compatible TV or computer micro-USB 2.0 (5-pin) port with mobile high-definition video link (MHL) for USB or HDMI connection (Special cable required for HDMI connection.) |
Pozn. |
Pdf file
Video - záznam a kvalita videa HTC One S
**VIDEO YOUTUBE
Delete - unistal app from testing device - emulator and try again RUN - DEBUGG your app.
Editace: 2011-10-04 08:57:45
Počet článků v kategorii: 396
Url:do-while-cycle-java-basic-example