Get Resource ID by Resources String Name Android example
// image from res/drawable
int resID = getResources().getIdentifier("my_image",
"drawable", getPackageName());
// view
int resID = getResources().getIdentifier("my_resource",
"id", getPackageName());
// string
int resID = getResources().getIdentifier("my_string",
"string", getPackageName());
396LW NO topic_id
AD
Další témata ....(Topics)
RadioButton RadioGroup Android example source code for Android developer
Example for *.xml files
Example for *.java files
Example for *.xml files
<RadioGroup android:id="@+id/idRadio_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:orientation="vertical">
<RadioButton android:id="@+id/idRadio_1"
android:text="@string/textLabel_1"/>
<RadioButton android:id="@+id/idRadio_2"
android:text="@string/textLabel_2"/>
<RadioButton android:id="@+id/idRadio_3"
android:text="@string/textLabel_3"/>
</RadioGroup>
Example for *.java files
// import
import android.widget.RadioGroup;
// get handle of RadioGroup
RadioGroup mRadioGroup = (RadioGroup) findViewById(R.id.idRadio_group);
// which RadioButton is selected for example in some function body
int nUnits = 10; // decimetry
int nIdRadio = mRadioGroup.getCheckedRadioButtonId();
if(nIdRadio == R.id.idRadio_1) nUnits = 1; // metr
else if(nIdRadio == R.id.idRadio_2) nUnits = 10; // decimetr
else if(nIdRadio == R.id.idRadio_3) nUnits = 100; // cm
else if(nIdRadio == R.id.idRadio_4) nUnits = 1000; // mm
// listener for RadioGroup Java Android example
mRadioGroup.setOnCheckedChangeListener(
new RadioGroup.OnCheckedChangeListener() {
public void onCheckedChanged(RadioGroup group,
int checkedId) {
Log.v("Selected", "New radio item selected: " + checkedId);
recordNewUIState();
}
});
Try convert WAV file to MP3 format for example by Audacity sound editor and replay:
//audacity.sourceforge.net/help/faq_i18n?s=install&i=lame-mp3
//audacity.sourceforge.net/help/faq_i18n?s=install&i=lame-mp3
MediaPlayer mp = MediaPlayer.create(getApplicationContext(), R.raw.mymp3file);
mp.setLooping(true);
mp.start();
Brand | Samsung |
Model (codename) | Galaxy Mini (S5570) |
Price (cena, včetně DPH) | 3500 / 06.2012 |
Display size in Inch (v palcích) | 3.14 |
Display-resolution | 240x320 |
Dotek-typ | kapacitní |
CPU typ | MSM7227 |
CPU MHz | 600 |
CPU core | |
L2 cache | yes |
RAM | 256 |
ROM | 512 |
GPU | Adreno 200 |
NenaMark2 Benchmark | |
GPU-GLBenchmark | |
Baterie mAh | 1200 |
Foto MPx | 3 |
Autofocus | no |
Video | QVGA (320 x 240) při 15 frames/s |
Official Android ICS | Android Froyo 2.2 |
CyanogenMod support | yes |
Dotek-prstů-max | Dual-touch (two fingers) |
Display-ppi | 127 |
Display-retina | 39% |
Networks | GSM&EDGE (850 / 900 / 1.800 / 1.900 MHz) 3G (900 / 2.100 MHz) |
Connectivity | Bluetooth V2.1 , USB V2.0 , USB mass storage , SyncML(DM) , WIFI , AGPS, 3.5 mm jack |
Note |
Samsung S5570 Galaxy Mini - image
Try this trick.
In AndroidManifest - activity tag write this code
App hold data of a views if will to rotation of device.
In AndroidManifest - activity tag write this code
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
App hold data of a views if will to rotation of device.
<activity
android:name=".Tests_Activity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
Dialog Yes No sample code
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Are you sure you want to exit application?")
.setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
MyActivity.this.finish(); //Close this Activity for example: MyActivity.java
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// some code if you want
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
Editace: 2011-11-19 13:07:25
Počet článků v kategorii: 396
Url:get-resource-id-by-resources-string-name-android-example