Get package name Context-getPackageName Android example
If you often copy your Android project to another you have to using function for obtaining varied information about package.
This code show how get package name in Android application as string:
This code show how get package name in Android application as string:
Context context = getContext(); // this.getContext(); getApplicationContext(); etc.
String sPackName = context.getPackageName();
396LW NO topic_id
AD
Další témata ....(Topics)
The source attachment does not contain the source for the file TextWatcher.class.
You can change the source attachment by clicking Change Attached Source below:
You have to add JDK src.zip path to dialog as on image below.
[caption id="attachment_1091" align="alignleft" width="282" caption="class file editor source not found Eclipse warning"][/caption]
Or go to Project > Properties > Java Build Path > Libraries
Expand JRE System Library. Expand rt.jar.
Select Source attachment and double click or Edit.
Type path the source code file (External File…) and press OK.
[caption id="attachment_1094" align="alignleft" width="300" caption="Java project build path"][/caption]
[caption id="attachment_1105" align="alignleft" width="300" caption="Java JRE deifiniton path in Eclipse"][/caption]
Now if mouse move about keywords String or F3 on keywords and press button in yellow field will opened String.class
You can change the source attachment by clicking Change Attached Source below:
You have to add JDK src.zip path to dialog as on image below.
[caption id="attachment_1091" align="alignleft" width="282" caption="class file editor source not found Eclipse warning"][/caption]
Or go to Project > Properties > Java Build Path > Libraries
Expand JRE System Library. Expand rt.jar.
Select Source attachment and double click or Edit.
Type path the source code file (External File…) and press OK.
[caption id="attachment_1094" align="alignleft" width="300" caption="Java project build path"][/caption]
Or type path in Java JRE definition
[caption id="attachment_1105" align="alignleft" width="300" caption="Java JRE deifiniton path in Eclipse"][/caption]
How open String.class or others keywords definition with Eclipse.
Now if mouse move about keywords String or F3 on keywords and press button in yellow field will opened String.class
Samsung S6102 Galaxy Y Duos umožňuje pracovat se dvěma aktivními SIM kartami a má GPS navigaci. Cena cca 4.500 korun / léto 2012.
Displej
Rozlišení displeje 320 x 240
Velikost displeje 3.14 "
Počet barev 262000
Rozměry 104 mm x 60 mm x 11.5 mm
Fotoaparát 3 Mpix, natačení videosekvencí
Operační system Android 2.3 (Gingerbread)
Procesor 832 MHz
Funkce Dual sim, Změny velikosti písma, Java, Internetový prohlížeč Přehrávání MP3, jack 3,5, Psaní SMS a e-mailů Multimediální zprávy MMS, Dlouhé SMS, Emailový prohlížeč, Kontakty a volání Hlasité handsfree, MP3/WMA/AAC vyzvánění, Skupiny volajících, Baterie
Typ baterie Li-Ion 1300 mAh
Doba hovoru 370 min
Pohotovostní doba 440 hodin
Uživatelská paměť 160 MB
Datové funkce GPS modul, WiFi, Bluetooth, GPRS, EDGE, Hardwarový modem
Aplikace Diktafon, Kalendář, FM rádio, Záznamník hovoru, Hry v telefonu, Kalkulačka, Budík
Mobilní telefony Samsung mají velmi dobrý poměr KVALITA / CENA
Displej
Rozlišení displeje 320 x 240
Velikost displeje 3.14 "
Počet barev 262000
Rozměry 104 mm x 60 mm x 11.5 mm
Fotoaparát 3 Mpix, natačení videosekvencí
Operační system Android 2.3 (Gingerbread)
Procesor 832 MHz
Funkce Dual sim, Změny velikosti písma, Java, Internetový prohlížeč Přehrávání MP3, jack 3,5, Psaní SMS a e-mailů Multimediální zprávy MMS, Dlouhé SMS, Emailový prohlížeč, Kontakty a volání Hlasité handsfree, MP3/WMA/AAC vyzvánění, Skupiny volajících, Baterie
Typ baterie Li-Ion 1300 mAh
Doba hovoru 370 min
Pohotovostní doba 440 hodin
Uživatelská paměť 160 MB
Datové funkce GPS modul, WiFi, Bluetooth, GPRS, EDGE, Hardwarový modem
Aplikace Diktafon, Kalendář, FM rádio, Záznamník hovoru, Hry v telefonu, Kalkulačka, Budík
Mobilní telefony Samsung mají velmi dobrý poměr KVALITA / CENA
Code with error:
If you get error try this code:
java.lang.ClassCastException: android.view.ViewGroup$LayoutParams
at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:659)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:311)
at android.view.View.measure(View.java:8313)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1017)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:386)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:309)
at android.view.View.measure(View.java:8313)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
at android.view.View.measure(View.java:8313)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:531)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:309)
at android.view.View.measure(View.java:8313)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
at android.view.View.measure(View.java:8313)
ImageView imgV = (ImageView)findViewById(R.id.myView);
imgV.setLayoutParams(new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
0));
If you get error try this code:
ViewGroup.LayoutParams layoutParams = imgV
.getLayoutParams();
layoutParams.height = 0;
imgV.setLayoutParams(layoutParams);
java.lang.ClassCastException: android.view.ViewGroup$LayoutParams
at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:659)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:311)
at android.view.View.measure(View.java:8313)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1017)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:386)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:309)
at android.view.View.measure(View.java:8313)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
at android.view.View.measure(View.java:8313)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:531)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:309)
at android.view.View.measure(View.java:8313)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
at android.view.View.measure(View.java:8313)
Android development
Java float is 32 bit single precision type and used when fractional precision calculation is required.
Java float je 32 bitů veliké číslo sloužící především pro přesný výsledek za desetinnou tečkou například při dělení čísel. Pro větší přesnost použíijte 64 bitový typ Double.
Java float is 32 bit single precision type and used when fractional precision calculation is required.
Java float je 32 bitů veliké číslo sloužící především pro přesný výsledek za desetinnou tečkou například při dělení čísel. Pro větší přesnost použíijte 64 bitový typ Double.
// declaration and assignment of value type float
float x = 18.41785f;
//print formated value
System.out.printf("The value of x is %.3f%n", x); // 18.418
// declaring more variables in single statement
float f1 = 12.4F, f2 = 564.5F, f3 = 14.589F;
// float range of value
System.out.println(Float.MIN_VALUE); // 4E-45
System.out.println(Float.MAX_VALUE); // 4028235E38
// is NaN Not-a-Number
float f = (float) Math.sqrt(-15);
boolean bNaN = Float.isNaN(f);
System.out.print(bNaN); // true
// check if a string is a valid number in Java example
// convert string to float Java example
String sF = "12.8";
float fParse = Float.parseFloat(sF);
// convert strings to numbers
String sFl = "15.48";
float fFromString = (Float.valueOf(sFl)).floatValue();
// float to string in Java example code
Float fObj = new Float(68.5);
String str = fObj.toString();
// else
Float fS = 11.6f;
String sFloat = fS.toString();
// compare two float variables
Float fComp1 = 4.3f;
if(fComp1.equals(4.3f))
System.out.print("true");
// compares the two specified float values in Java example
int i = Float.compare(11.5f, 11.7f); // -1 first < second
// 0 first == second
// 1 first > second
System.out.print(i);
Window>Preference>Java>Editor>Typing and check the "Escape text when pasting into a string literal".
Editace: 2011-09-26 20:47:18
Počet článků v kategorii: 396
Url:get-package-name-context-getpackagename-android-example