February 6th, 2012, 01:50 PM
|
#1 (permalink)
|
|
New Member
Join Date: Feb 2012
Posts: 3
Device(s):
Thanks: 0
Thanked 0 Times in 0 Posts
|
Android/Eclipse, connecting radio button selections to Checkbox selections
I am coding an android application and i have 2 radio buttons (in a radiogroup) that i want to control the behavior selection for checkboxes...so when i select radio button 1 (which equals 9 choices) should allow the user to only check 9 Checkboxes (even if there are twenty checkboxes. This is my code so far, am stuck
Code:
public class Main extends Activity{ Button button; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); addListenerOnButton(); final RadioButton radio0 = (RadioButton) findViewById(R.id.radio0); final RadioButton radio1 = (RadioButton) findViewById(R.id.radio1); radio0.setOnClickListener(radio_listener); radio1.setOnClickListener(radio_listener); } public OnClickListener radio_listener = new OnClickListener() { public void onClick(View v) { // Perform action on clicks RadioButton rb = (RadioButton) v; // allow user only to select 9 or 18 check box choices } }); } }
|
|
|