Usage of Radio Group and radio Button

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Usage of Radio Group and radio Button

Postby and.modi » Tue Nov 18, 2008 1:45 am

Hi,
I m using RadioGroup and RadioButton in my UI.
I am displaying 5 radio buttons and want to selecet one.
I get the UI and I m diplaying five levels for my game.
I am not sure that how can I read that back in the program?
Means if user select first radio button, I want to change the level value = 1,
but if user selects second radio button, I want that value = 2.

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <?xml version="1.0" encoding="utf-8"?>
  3.  
  4. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  5.  
  6.    android:orientation="vertical"
  7.  
  8.    android:layout_width="fill_parent"
  9.  
  10.    android:layout_height="fill_parent"
  11.  
  12.    android:background="@drawable/backplane"
  13.  
  14.    >
  15.  
  16.     <RadioGroup
  17.  
  18.         android:id="@+id/selectlevelgroup"
  19.  
  20.         android:layout_width="fill_parent"
  21.  
  22.             android:layout_height="wrap_content"
  23.  
  24.         >
  25.  
  26.         <RadioButton
  27.  
  28.                 android:text = "Level 1"
  29.  
  30.                 android:id = "@+id/level1"
  31.  
  32.                 >
  33.  
  34.         </RadioButton>
  35.  
  36.         <RadioButton
  37.  
  38.                 android:text = "Level 2"
  39.  
  40.                 android:id = "@+id/level2"
  41.  
  42.                 >
  43.  
  44.         </RadioButton>
  45.  
  46.         <RadioButton
  47.  
  48.                 android:text = "Level 3"
  49.  
  50.                 android:id = "@+id/level3"
  51.  
  52.                 >
  53.  
  54.         </RadioButton>
  55.  
  56.         <RadioButton
  57.  
  58.                 android:text = "Level 4"
  59.  
  60.                 android:id = "@+id/level4"
  61.  
  62.                 >
  63.  
  64.         </RadioButton>
  65.  
  66.         <RadioButton
  67.  
  68.                 android:text = "Level 5"
  69.  
  70.                 android:id = "@+id/level5"
  71.  
  72.                 >
  73.  
  74.         </RadioButton>
  75.  
  76.                
  77.  
  78.     </RadioGroup>      
  79.  
  80. </LinearLayout>
  81.  
  82.  
Parsed in 0.004 seconds, using GeSHi 1.0.8.4


And also,
if user makes one selection and changes after that, does the assinment
chages dynamically?

Thanks,
Mitul Modi
Attachments
radio.JPG
UI design of the screen which uses radiobutton.
radio.JPG (20.85 KiB) Viewed 175 times
and.modi
Junior Developer
Junior Developer
 
Posts: 14
Joined: Sat Jul 26, 2008 9:17 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 9 guests