Okhelp.cz

Recepty, články, nápady, programování. Dříve dum-zahrada, finance, internet a know-how.okhelp.cz Pro lepší výsledky hledání používejte i diakritiku.

RadioButton RadioGroup Java Android example



RadioButton RadioGroup Android example source code for Android developer
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();
                    }
                });




397LW NO topic_id



Další témata ....(Topics)


351

Android Studio bug versioncode versionname signed apk issue | android-studio-bug-versioncode-versionname-signed-apk-issue


If you change android:versionCode="224" and android:versionName="2.2.4" in AndroidManifest.xml you have to change this in build.gradle file too.
Click on build.gradle in package explorer tree change your new version name and code:


  defaultConfig {
        applicationId "cz.okhelp.pocasiwidget"
        minSdkVersion 11
        targetSdkVersion 23
        versionCode 224
        versionName "2.2.4"
    }
168

Android SDK Samples as a Photo Gallery | android-sdk-samples-as-photo-serial


Photo Gallery of Android SDK Samples.
For better understanding of what the source knows there is a gallery of images.
After clicking on the preview displays the actual size and Titlebar
You can read the path to the source file as: Graphics/AnimateDrawables see the project folder
/ApiDemos/src/com/example/android/apis/graphics/AnimateDrawable.java


395

Unchecked call to add(E) as a member of raw type java.util.List | unchecked-call-to-adde-as-a-member-of-raw-type-java-util-list



// warnning
private List list = new ArrayList();

// ok /put type of added object
private List<String> list = new ArrayList<String>();
226

Eclipse my templates store Android | eclipse-my-templates-store-android


Where file(s) does eclipse store Java code style settings to?
If you need copy any old templates to the new workspace.

workspace\.metadata\.plugins\org.eclipse.core.runtime\.settings\org.eclipse.jdt.ui.prefs


You can edit the Eclipse Templates from menu Window - Preferences - Java - Editor - Templates.
283

addPreferencesFromResource Deprecated Android Code Warning | addpreferencesfromresource-deprecated-android-code-warning


Put extends PreferenceFragment API level 11 instead PreferenceActivity

public class SettingsActivity extends PreferenceFragment {
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      addPreferencesFromResource(R.xml.preferences);
  }
}

// or insert suppresswarning
public class SettingsActivity extends PreferenceActivity {
  @SuppressWarnings("deprecation")
	@Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      addPreferencesFromResource(R.xml.preferences);
  }
}



Editace Jana Žákovská : 2011-09-26 20:48:27
Počet článků v kategorii: 397
Url:radiobutton-radiogroup-android-example
Share
Share
Tweet