Presentation is loading. Please wait.

Presentation is loading. Please wait.

GUI Components 1 Fall 2012 CS2302: Programming Principles.

Similar presentations


Presentation on theme: "GUI Components 1 Fall 2012 CS2302: Programming Principles."— Presentation transcript:

1 GUI Components 1 Fall 2012 CS2302: Programming Principles

2 Radio Button  xml file <RadioGroup android:id="@+id/radioGroup1" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <RadioButton android:id="@+id/radio0" android:layout_width="wrap_content" android:layout_height="wrap_content" android:checked="true" android:text=“radiobutton" /> …… Fall 2012 CS2302: Programming Principles 2

3 Radio Button Fall 2012 CS2302: Programming Principles 3 .java file 1. Find the RadioGroup using the method findViewById 2. Create a class implements the interface RadioGroup.onCheckedChangeListener 3. Implement onCheckedChanged method 4. Bind the listener class to the RadioGroup using the method setOnCheckedChangeListener 5. Find the checked RadioButton ID using the method radiogroupname. getCheckedRadioButtonId() ;

4 Check Box Fall 2012 CS2302: Programming Principles 4  xml file <CheckBox android:id="@+id/checkbox1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:text="@string/checkbox1" />

5 Check Box Fall 2012 CS2302: Programming Principles 5 .java file 1. Find the CheckBox using the method findViewById 2. Create a class implements the interface CompoundButton.onCheckedChangeListener 3. Implement onCheckedChanged method 4. Bind the listener class to the CheckBox using the method setOnCheckedChangeListener 5. To check whether the CheckBox is checked using the method isChecked() ;

6 Seek Bar Fall 2012 CS2302: Programming Principles 6  xml file <SeekBar android:id="@+id/seekBar1" android:layout_width=“fill_parent" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:max="44" android:progress="29" />

7 Seek Bar Fall 2012 CS2302: Programming Principles 7 .java file 1. Find the SeekBar using the method findViewById 2. Create a class implements the interface SeekBar.onSeekBarChangeListener 3. Implement onProgressChanged method 4. Bind the listener class to the SeekBar using the method setOnSeekBarChangeListener 5. To check the current progress of the SeekBar using the method getProgress() ;


Download ppt "GUI Components 1 Fall 2012 CS2302: Programming Principles."

Similar presentations


Ads by Google