Android单选和多选择按钮
2010-10-12 02:13:00 来源:本站整理38. System.out.println("famale");
39. Toast.makeText(RadioTest.this, "famle", Toast.LENGTH_SHORT).show();
40. }
41. else if(maleButton.getId() == checkedId)
42. {
43. System.out.println("male");
44. }
45. }
46. });
47.
48. //为多选按钮添加监听器
49. swimBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
50.
51. @Override
52. public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
53. // TODO Auto-generated method stub
54. if(isChecked)
55. {
56. System.out.println("swim is checked");
57. }
58. else
59. {
60. System.out.println("swim is unchecked");
61. }
62. }
63. });
64. runBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
65.
66. @Override
67. public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
68. // TODO Auto-generated method stub
69. if(isChecked)
70. {
71. System.out.println("run is checked");
72. }
73. else
74. {
75. System.out.println("run is unchecked");
76. }
77. }
78. });
79. readBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
80.
81. @Override
82. public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
83. // TODO Auto-generated method stub
84. if(isChecked)
85. {
86. System.out.println("read is checked");
87. }
88. else
89. {
90. System.out.println("read is unchecked");
更多精彩
赞助商链接