Spinner ComboBox DropDown set on selected item listener setOnItemSelectedListener Java Android example
Spinner, ArrayAdapter, setOnItemSelectedListener, onItemSelected, setDropDownViewResource
MainClass.java
strings.xml
MainClass.java
public class Vypocet extends Activity {
Spinner hSpinnerMetry;
// .......
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
hSpinnerMetry = (Spinner) findViewById(R.id.idSpinnerMetry);
ArrayAdapter<CharSequence> adapterMetry = ArrayAdapter.createFromResource(
this, R.array.metry_array, android.R.layout.simple_spinner_item);
adapterMetry.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
hSpinnerMetry.setAdapter(adapterMetry);
hSpinnerMetry.setOnItemSelectedListener(
new OnItemSelectedListener() {
public void onItemSelected(
AdapterView<?> parent, View view, int position, long id) {
int nPos = position;
}
public void onNothingSelected(AdapterView<?> parent) {
}
});
}
}
strings.xml
<string-array name="metry_array">
<item>m</item>
<item>dm</item>
<item>cm</item>
<item>mm</item>
</string-array>
396LW NO topic_id
AD
Další témata ....(Topics)
How to resize an image in ImageView Android source code.
Resize imageview layout and image will resize too:
Resize imageview layout and image will resize too:
public void resizeImageView(int width, int height) {
final ImageView picture1 = (ImageView)findViewById(R.id.imageView1);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(width, height);
picture1.setLayoutParams(layoutParams);
}
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lcz/okhelp/MyMathClass;
First try this solution!!!!!
Select your project in project tree and go to the Eclipse menu Project » Clean » Clean projects selected below » select your project and click OK.
If you create *.apk package with proguard sometimes you must back up the project, delete project, and create new project if you are unable to create *.apk file.
Check your AndroidManifest.xml if all Activity is correctly inserted. If you add a library project to Main project you have to insert Activity from library to Main project AndroidManifest.xml
Problem with the library.
I deleted library project from project tree and again put the _library project into the main project. This problem was resolved.
1.)Go to Project » Properties » Java Build Path » Libraries and remove (your projects) click OK.
2.)Go to Project » Clean » Clean projects selected below » select your project and click OK.
3.)Add again your LIBRARY project to your MAIN project Project » Properties » Java Build Path » Libraries.
See image below.
Problem with a *.apk file
If you create signed *.apk, you have to delete previous *.apk from your PC folder.
java.lang.IllegalArgumentException: already added: Lcz/okhelp/MyMathClass;
First try this solution!!!!!
Select your project in project tree and go to the Eclipse menu Project » Clean » Clean projects selected below » select your project and click OK.
If you create *.apk package with proguard sometimes you must back up the project, delete project, and create new project if you are unable to create *.apk file.
Check your AndroidManifest.xml if all Activity is correctly inserted. If you add a library project to Main project you have to insert Activity from library to Main project AndroidManifest.xml
Problem with the library.
I deleted library project from project tree and again put the _library project into the main project. This problem was resolved.
1.)Go to Project » Properties » Java Build Path » Libraries and remove (your projects) click OK.
2.)Go to Project » Clean » Clean projects selected below » select your project and click OK.
3.)Add again your LIBRARY project to your MAIN project Project » Properties » Java Build Path » Libraries.
See image below.
Problem with a *.apk file
If you create signed *.apk, you have to delete previous *.apk from your PC folder.

Code look up at the Api Demos
android_fragments arguments attributes - three fragments on screen
android_fragments_alert_dialog
android_fragments_context_menu
android_fragments_custom_animation
android_fragments_dialog
android_fragments_dialog_or_activity
fragment_hide_show
fragment_layout
fragments_list_array
fragment_menu
android_fragments_get_result_from_fragment and tabs in two rows
android_fragments_recive_result
android_fragments_stack
fragment_tabs
android_fragments arguments attributes - three fragments on screen

android_fragments_alert_dialog

android_fragments_context_menu

android_fragments_custom_animation

android_fragments_dialog

android_fragments_dialog_or_activity

fragment_hide_show

fragment_layout

fragments_list_array

fragment_menu

android_fragments_get_result_from_fragment and tabs in two rows

android_fragments_recive_result

android_fragments_stack

fragment_tabs

HTC Sensation 4G cena od 11 000 KCZ Kč (únor.2012)
Spokojenost uživatelů nadprůměrná.
HTC Sensation 4G je chytrý telefon s operačním systémem Android.
HTC Sensation 4G je (22.února2012) 10. nejpoužívanějším chytrým telefonem u programu Sky Map viz tabulka.
Výrobce HTC
Kompatibilní sítě GSM / GPRS / EDGE
850 900 1800 1900 MHz
UMTS / HSPA
850 1900 2100 nebo 900 1700 2100 MHz
HSDPA 14,4 Mbps
HSUPA 5.76 Mbps
První předvedení 19.května 2011
Zaváděcí cena US 199,99 dolarů
Nástupce HTC Sensation XE, HTC 4G Amaze
Rozměry 126.1 mm (4.96 v) H
65.4 mm 2,57 in) W
11.3 mm (0,44 in) D
Hmotnost 148 g
Operační systém Android 2.3.3 Gingerbread (upgrade až na 2.3.4),
HTC Sense 3.0 overlay
Procesor:
Dual-core CPU, 1.2 GHz Qualcomm MSM8260 Snapdragon, Sensation XE dual-core 1,5 GHz Qualcomm MSM8260 Snapdragon, Sensation XL jednoho jádra 1,5 GHz Qualcomm MSM8255 Snapdragon
GPU Qualcomm adreno 220, Sensation XL adreno 205
Paměť 768 MB RAM
4 GB (1 GB uživatelsky dostupných)
Paměť vyjmutelná: 8 GB microSD 2.0, podporuje až 32 GB
Baterie 1520 mAh vnitřní dobíjecí Li-ion vyměnitelné
Datové vstupy A-GPS, čidlo okolního osvětlení, digitální kompas, G-senzor, gyroskop, multi-touch kapacitní dotykový displej, snímač
Displej 4.3 v (110 mm) kapacitní S-LCD dotykový displej Gorilla skla s QHD (540 × 960) rozlišením na 256.15 PPI
Fotoaparát na zadní straně s 8 miliony pixelů (3264 x 2448) s automatickým ostřením a dvojitým LED bleskem a 1080p HD video záznamu @ 30 snímků / s, kohoutek k zaměření s digitálním zoomem
Fotoaparát na přední straně VGA pevné zaostření barevná kamera (0,3 megapixelů)
Kompatibilní média formáty audio AAC, AMR, OGG, M4A, MIDI, MP3, WAV, WMA
Video 1920 × 1080 (1080p HD) @ 30 snímků / s - 3GP, .3 G2, MP4, WMV, AVI, XVID
Vyzváněcí tóny a oznámení všechny kompatibilní audio formáty
Vibrace
Připojení 3.5 mm TRRS konektor, Bluetooth 3.0 s A2DP, FM přijímač (87,5 - 108 MHz) s RDS, Micro USB 2.0 (5-pin) port s Mobile High-Definition Link (MHL) pro USB nebo HDMI připojení, Wi-Fi 802.11b/g/n
Zdroj: wikipedia
HTC Sensation 4G photo pic image
Zdroj obrázku: wikipedia
Spokojenost uživatelů nadprůměrná.
HTC Sensation 4G je chytrý telefon s operačním systémem Android.
HTC Sensation 4G je (22.února2012) 10. nejpoužívanějším chytrým telefonem u programu Sky Map viz tabulka.
Výrobce HTC
Kompatibilní sítě GSM / GPRS / EDGE
850 900 1800 1900 MHz
UMTS / HSPA
850 1900 2100 nebo 900 1700 2100 MHz
HSDPA 14,4 Mbps
HSUPA 5.76 Mbps
První předvedení 19.května 2011
Zaváděcí cena US 199,99 dolarů
Nástupce HTC Sensation XE, HTC 4G Amaze
Rozměry 126.1 mm (4.96 v) H
65.4 mm 2,57 in) W
11.3 mm (0,44 in) D
Hmotnost 148 g
Operační systém Android 2.3.3 Gingerbread (upgrade až na 2.3.4),
HTC Sense 3.0 overlay
Procesor:
Dual-core CPU, 1.2 GHz Qualcomm MSM8260 Snapdragon, Sensation XE dual-core 1,5 GHz Qualcomm MSM8260 Snapdragon, Sensation XL jednoho jádra 1,5 GHz Qualcomm MSM8255 Snapdragon
GPU Qualcomm adreno 220, Sensation XL adreno 205
Paměť 768 MB RAM
4 GB (1 GB uživatelsky dostupných)
Paměť vyjmutelná: 8 GB microSD 2.0, podporuje až 32 GB
Baterie 1520 mAh vnitřní dobíjecí Li-ion vyměnitelné
Datové vstupy A-GPS, čidlo okolního osvětlení, digitální kompas, G-senzor, gyroskop, multi-touch kapacitní dotykový displej, snímač
Displej 4.3 v (110 mm) kapacitní S-LCD dotykový displej Gorilla skla s QHD (540 × 960) rozlišením na 256.15 PPI
Fotoaparát na zadní straně s 8 miliony pixelů (3264 x 2448) s automatickým ostřením a dvojitým LED bleskem a 1080p HD video záznamu @ 30 snímků / s, kohoutek k zaměření s digitálním zoomem
Fotoaparát na přední straně VGA pevné zaostření barevná kamera (0,3 megapixelů)
Kompatibilní média formáty audio AAC, AMR, OGG, M4A, MIDI, MP3, WAV, WMA
Video 1920 × 1080 (1080p HD) @ 30 snímků / s - 3GP, .3 G2, MP4, WMV, AVI, XVID
Vyzváněcí tóny a oznámení všechny kompatibilní audio formáty
Vibrace
Připojení 3.5 mm TRRS konektor, Bluetooth 3.0 s A2DP, FM přijímač (87,5 - 108 MHz) s RDS, Micro USB 2.0 (5-pin) port s Mobile High-Definition Link (MHL) pro USB nebo HDMI připojení, Wi-Fi 802.11b/g/n
Zdroj: wikipedia
HTC Sensation 4G photo pic image
Zdroj obrázku: wikipedia
Example source code for Android Developers
// clickable TextView
public TextView createTextView(String sText, Context con){
TextView b = null;
try {
b = new TextView (con);
b.setTextSize(15.0f);
b.setTextColor(Color.rgb( 0, 0, 200));
b.setOnClickListener(this);
b.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
b.setText(sText);
//tr.addView(b, 60,30);
} catch (Exception e) {
e.printStackTrace();
return b;
}
return b;
}
/*****************/
public void onClick(View view) {
try {
String s = ((TextView) view).getText().toString();
}
catch (Exception e1) {
e1.printStackTrace();
}
}
/***********/
// if you want restore in TextView after chagne of orientation
// you have to put code to Manifest.xml android:configChanges
activity android:name=".main"
android:label="@string/app_name"
android:configChanges="keyboardHidden|orientation" //this line important !!!!!!!
Editace: 2011-09-19 07:36:08
Počet článků v kategorii: 396
Url:spinner-combobox-set-on-selected-item-listener-setonitemselectedlistener-java-android-example