,html实现单项选择题择

当前位置:
>>>单项选择。 —Can I help you?— I want ____, please. [ ]A. t..
单项选择。
—&Can I help you?&— I want ____, please.
A. two socksB. two pair of socks C. two pairs of socks D. two pairs of sock
题型:单选题难度:中档来源:专项题
马上分享给同学
据魔方格专家权威分析,试题“单项选择。 —Can I help you?— I want ____, please. [ ]A. t..”主要考查你对&&可数名词(单数名词,复数名词),量词&&等考点的理解。关于这些考点的“档案”如下:
现在没空?点击收藏,以后再看。
因为篇幅有限,只列出部分考点,详细请访问。
可数名词(单数名词,复数名词)量词
可数名词:是指能以数目来计算,可以分成个体的人或东西;因此它有复数形式,当它的复数形式在句子中作主语时,句子的谓语也应用复数形式。 名词单数变复数的规则:
巧记以f\fe结尾的可数名词复数妻子骑牛拿起刀,wife,calf,knife ↑追得贼狼满街跑,thief,wolf →→→变f或fe为v,再加es碰倒架子丧己命,shelf,self,life ↓手帕树叶半空飘。handkerchief,leaf,half ↓名词复数的不规则变化:1.不规则形式:child→children(儿童)man→men(男人)woman→women (女人)an Englishman→two Englishmen(英国人)foot→feet(脚)tooth→teeth(牙)mouse→mice(老鼠)ox →oxen(公牛)goose→geese(鹅)2.单复同形:deer,sheep,fish,Chinese,Japanese, species,means,Swiss除人民币,美元、英镑、法郎等都有复数形式。如:a dollar, a meter,twometers3.集体名词,以单数形式出现,但实为复数:people police cattle是复数(OK :a person,a policeman,ahead of cattle,the English,the British,the French,the Chinese,the Japanese,the Swiss )(Error:a people,a police,a cattle )表示国民总称时,作复数用。(The Chinese are industries and brave. 中国人民是勤劳勇敢的。)4.以s结尾,仍为单数的名词maths,politics,physics等学科名词,为不可数名词,是单数。news是不可数名词。5.表示由两部分构成的东西,glasses(眼镜) trousers (长裤) clothes(衣服)若表达具体数目,要借助数量词pair(对,双)a pair of glasses& two pairs of trousers suit(套)6.另外还有一些名词,其复数形式有时可表示特别意思goods (货物) waters (水域) fishes (各种鱼)可数名词变复数的几种形式:&1) 单数名词加s: students, apples, bags, trees, books, brothers.  &2) 以s、x、sh、ch结尾的名词加es: glasses, boxes, brushes, matches.   3) 以辅音字母加y结尾的名词,变y为i加es: cities, babies, enemies.    4) 以f或fe结尾的名词,多数变f为v加es: wives, knives.但有些词只加s: roofs,proofs, chiefs. &5) 以o结尾的名词,有些加es: Negroes, heroes, tomatoes, potatoes.&&其它加s: radio s, zoos, pianos, photos.    6) 不规则名词:foot→feet, goose→geese, tooth→teeth, child→children, man→men, woman→women, mouse→mice. 7) 单复数同形的名词:sheep,fish,dee. 注意:fish表示种类时,也用fishes这样的形式。 量词:通常用来表示人、事物或动作的数量单位的词,叫做量词。例如:a bag of (rice), a piece of (news), a cup of (tea) 量词特点:在英语中,有很多量词词组,例如:a group of,a flock of, a bunch of,a bundle of等等.量词词组粗略地归纳了以下的特点,具体表现为:特点一:英语量词词组所表示的数或量,大致可归纳为四种类型,即定量、不定量、大量和少量。1.表示定量的量词词组,譬如:a couple of(两个、一对)a couple of days,a couple of players,a couple of times;a cupful of(一满杯)a cupful of jelly,a cupful of water;a portion of(一份/客)a portion of duck,a portion of roast beef。2.表示不定量的量词词组,譬如:a majority of(大多数/大半)a majority of opinions,a majority of votes;an atom of(一点)an atom of food,an atom of truth;a spell of(一阵/一段时间)a spell of fine weather,a spell of coughing。3.表示大量的量词词组,譬如:a flood of—a flood of ink(洋洋大篇),a flood of tears(泪如泉涌);a heap of—a heap of earth(一堆泥土),a heap of customers(许多顾客);a mountain of—a mountain of debts(债台高筑),a mountain of difficulties(困难重重)。4.表示少量的量词词组,譬如:a drop of—a drop of fever(有点热度),a drop of dew(一点露水);a particle of—a particle of feeling(一丝感情),a particle of dust(一点灰尘);a shadow of—a shadow of doubt(一点怀疑),a shadow of freedom(一点自由)。
特点二:有些数量词组修饰可数名词,有些数量词组修饰不可数名词,还有些则两者均可修饰。1.修饰不可数名词的量词词组,譬如:a bit of—a bit of English(一点英语),a bit of good advice(一些好意见),a bit of interest(一点兴趣);a shred of—a shred of evidence(一点证据),a shred of cloth(少量布),a shred of reputation(一点声誉),a sheet of—a sheet of glass(一块玻璃),a sheet of water(一片汪洋)。2.修饰可数名词的量词词组,譬如:a cluster of—a cluster of flowers(一簇花),a cluster of spectators(一群观众),a cluster of bright stars(闪烁群星);a string of—a string of pearls(一串珠子),a string of curses(连续不断的咒骂),a string of excuses(一连串借口);a scram of—a scram of mosquitoes(一群蚊子),a scram of geese(一群鹅),a scram of children(一群孩子)。3.修饰(不)可数名词的量词词组,譬如:a body of—a body of bees(一群蜜蜂),a body of cold air(一股冷空气),a body of facts(许多事实);a block of—a block of ice(一大块冰),a block of flats(一幢公寓),a block of houses(一排房子);a chain of—a chain of ideas(一系列想法),a chain of accidents(一连串事故),a chain of proof(一连串证据)。
特点三:有些数量词组的搭配是固定的,而有些搭配则比较灵活。1.搭配固定的量词词组,譬如:a barrel of—a barrel of beer(一桶啤酒),a barrel of crude oil(一桶原油);a basket of—a basket of eggs(一篮鸡蛋),a basket of apples(一篮苹果);a line of—a line of trees(一行树),a line of poetry(一行诗)。2.搭配较灵活的量词词组,譬如:a piece of—a piece of paper(一张纸),a piece of furniture(一件家具),a piece of equipment(一台设备);a round of—a round of spirit(一巡酒),a round of diplomatic talks(一轮外交谈判),a round of toast(一片烤面包);a bar of—a bar of chocolate(一块巧克力),a bar of soap(一条肥皂),a bar of light(一束光)。量词分类列举:常见的量词及搭配:1. 一般性的表示个数的量词:这一组中主要有piece, bit, item, article 等词,但piece具有独特的地位,在使用其他词的地方一般都可使用piece 代替之。比如:piece :a piece of meat/paper/bread/music/information/furniture/machinery, etc.一片肉/一张纸/一片面包/一首曲子/一条信息/一件家具/一台机器等bit :a bit of news/wood/advice/trouble, etc. 一条消息/一块木头/一条建议/一件麻烦事等item: an item of news/crime/program/business, etc. 一条新闻/一宗罪行/一个项目/一笔生意等article :an article of export/ furniture/ clothing/ luggage, etc. 一宗出口/一件家具/一件衣服/一件行李等2. 以形状表示个数的量词:bar :a bar of chocolate/candy 一块巧克力/一块糖bunch :a bunch of flowers/grapes/ keys 一束花/一串葡萄/一串钥匙cake: a cake of soap/ice一块肥皂/一块冰cluster :a cluster of stars/flowers/animals一群星/一束花/一群动物comb: a comb of bananas 一串香蕉drop :a drop of rain/ blood 一滴雨/一滴血ear :an ear of corn/wheat一棒玉米/一穗麦子flight :a flight of stairs/arrows/sparrows一段楼梯/一阵箭雨/一群麻雀flock: a flock of workmen/criminals/boys 一群工人/一伙罪犯/一群男孩head: a head of cabbage/cauliflower/sheep一头卷心菜/一块花菜/一头羊lump: a lump of sugar/coal/clay一块糖/一块煤/一块土spiral :a spiral of mosquito incense 一盘蚊香slice :a slice of meat/bread/beef一片肉/一片面包/一块牛肉swarm :a swarm of bees一群蜜蜂bevy a bevy of beauties/girls/ladies 一群美人/一群女孩/一群女士gathering a gathering of friends一帮朋友clump :a clump of trees一丛树林pack: a pack of rascals/wolves一群流氓/一群狼3. 表示容积的词:bottle:&a bottle of ink/milk/wine 一瓶酒/一瓶牛奶/一瓶葡萄酒bowl :a bowl of rice/porridge 一碗米饭/一碗粥pail::a pail of water 一桶水glass: a glass of beer 一杯啤酒cup: a cup of tea 一杯茶handful a handful of soil 一抔土spoonful :a spoonful of oil 一汤匙油mouthful :a mouthful of snow 一口雪truckload: a truckload of steel 一卡车钢材a packet of cigarette一包烟4. 表示行为动态的量词:fit :a fit of laughter 一阵笑声peal :a peal of thunder 一阵雷声flash :a flash of light 一道闪电display :a display of force 一番武力展示
发现相似题
与“单项选择。 —Can I help you?— I want ____, please. [ ]A. t..”考查相似的试题有:
1555166146858456152041129181125492您的举报已经提交成功,我们将尽快处理,谢谢!
学好英语贵在坚持,必。克。英。语,电话,他们每天都有课堂,在家就可以上,一对一外教上课,词汇量也不会落下,比较轻松也容易坚持,而且是实打实的小班课程 建议你去试...
我玩的羽毛``级别不算高``但技能都可以学了``1年了也算老羽毛了``个人观点如下:
`龙卷风 羽箭是基本攻击技能是必须学满的``羽箭是物理攻击`遇到法...
大家还关注Android学习笔记17:单项选择RadioButton和多项选择CheckBox的使用 -android100学习网
Android学习笔记17:单项选择RadioButton和多项选择CheckBox的使用
在Android中,可以通过RadioButton和RadioGroup的组合来实现单项选择的效果。而多项选择则是通过CheckBox来实现的。1.单项选择RadioButton  我们知
在Android中,可以通过RadioButton和RadioGroup的组合来实现单项选择的效果。而多项选择则是通过CheckBox来实现的。
1.单项选择RadioButton
  我们知道,一个单项选择是由两部分组成的,分别是前面的选择按钮和后面的“答案”。选择按钮可以通过RadioButton来实现,而“答案”则可以通过RadioGroup来实现。
  具体的实现步骤如下:
  首先,在布局文件中定义一个TextView控件,用来显示问题。
  然后,再在布局文件中定义一个RadioGroup控件,用来显示答案。
  最后,再在RadioGroup控件中定义四个(根据需求而定)RadioButton控件,并将“答案”分别赋给每个选项。
  如下是实现一个单项选择demo的xml布局文件源代码:
单项选择xml源代码
&1 &LinearLayout xmlns:android="/apk/res/android"
&2&&&& xmlns:tools="/tools"
&3&&&& android:orientation="vertical"
&4&&&& android:layout_width="match_parent"
&5&&&& android:layout_height="match_parent" &
&7&&&& &!-- 题干 --&
&8&&&& &TextView
&9&&&&&&&& android:id="@+id/textView"
10&&&&&&&& android:layout_marginTop="10dp"
11&&&&&&&& android:layout_width="match_parent"
12&&&&&&&& android:layout_height="wrap_content"
13&&&&&&&& android:text="Android底层基于以下哪一种操作系统?"&&& &&&
14&&&& &/TextView&
16&&&& &!-- 选项 --&
17&&&& &RadioGroup
18&&&&&&&& android:id="@+id/radioGroup"
19&&&&&&&& android:layout_width="match_parent"
20&&&&&&&& android:layout_height="wrap_content"
21&&&&&&&& android:orientation="vertical"&&& &
22&&&&&&&&
23&&&&&&&& &!-- 选项1 --&
24&&&&&&&& &RadioButton
25&&&&&&&&&&&& android:id="@+id/radioButton1"
26&&&&&&&&&&&& android:layout_width="match_parent"
27&&&&&&&&&&&& android:layout_height="wrap_content"
28&&&&&&&&&&&& android:text="Windows"&&& &&&&&&&&&&&&
29&&&&&&&& &/RadioButton&
31&&&&&&&& &!-- 选项2 --&
32&&&&&&&& &RadioButton
33&&&&&&&&&&&& android:id="@+id/radioButton2"
34&&&&&&&&&&&& android:layout_width="match_parent"
35&&&&&&&&&&&& android:layout_height="wrap_content"
36&&&&&&&&&&&& android:text="Linux"&&& &&&&&&&&&&&&
37&&&&&&&& &/RadioButton&
38&&&&&&&&
39&&&&&&&& &!-- 选项3 --&
40&&&&&&&& &RadioButton
41&&&&&&&&&&&& android:id="@+id/radioButton3"
42&&&&&&&&&&&& android:layout_width="match_parent"
43&&&&&&&&&&&& android:layout_height="wrap_content"
44&&&&&&&&&&&& android:text="Moc os"&&& &&&&&&&&&&&&
45&&&&&&&& &/RadioButton&&&&&&&&
47&&&&&&&& &!-- 选项4 --&
48&&&&&&&& &RadioButton
49&&&&&&&&&&&& android:id="@+id/radioButton4"
50&&&&&&&&&&&& android:layout_width="match_parent"
51&&&&&&&&&&&& android:layout_height="wrap_content"
52&&&&&&&&&&&& android:text="Java"&&& &&&&&&&&&&&&
53&&&&&&&& &/RadioButton&&&&&&&&
55&&&& &/RadioGroup&
57 &/LinearLayout&
  通过以上三个步骤,我们便可以很轻松的实现单项选择的效果了,上述demo源代码的运行效果如图1所示。
图1 单项选择界面
  因为是单项选择,所以各个选项之间存在互斥性,即仅能选中其中的某一个选项。那么如何来确定用户的选择是否正确,并给出相应的提示信息呢?
  要确定用户的选择是否正确,需要知道用户选择的是选项中的哪一项,这可以通过为RadioGroup设置事件监听器setOnCheckedChangeListener来实现。通过该事件监听器便可以判断出用户点击的是哪一个RadioButton了。然后,再使用Toast来显示相应的提示信息即可。
  用上述方案实现单项选择demo的java源代码如下:
单项选择java源代码
&1 package com.example.android_
&3 import android.os.B
&4 import android.view.G
&5 import android.widget.RadioB
&6 import android.widget.RadioG
&7 import android.widget.TextV
&8 import android.widget.T
&9 import android.app.A
11 public class MainActivity extends Activity {
13&&&& TextView mTextV&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& //TextView对象,用于显示问题
14&&&& RadioGroup mRadioG&&&&&&&&&&&&&&&&&& //RadioGroup对象,用于显示答案
15&&&& RadioButton mRadioButton_1;&&&&&&&&&&& //RadioButton对象,用于显示选项1
16&&&& RadioButton mRadioButton_2;&&&&&&&&&&& //RadioButton对象,用于显示选项2
17&&&& RadioButton mRadioButton_3;&&&&&&&&&&& //RadioButton对象,用于显示选项3
18&&&& RadioButton mRadioButton_4;&&&&&&&&&&& //RadioButton对象,用于显示选项4
20&&&& @Override
21&&&& public void onCreate(Bundle savedInstanceState) {
22&&&&&&&& super.onCreate(savedInstanceState);
23&&&&&&&& setContentView(R.layout.activity_main);&&&&&&&&&&&&&&& //加载布局文件
24&&&&&&&&
25&&&&&&&& //加载控件
26&&&&&&&& mTextView = (TextView)this.findViewById(R.id.textView);
27&&&&&&&& mRadioGroup = (RadioGroup)this.findViewById(R.id.radioGroup);
28&&&&&&&& mRadioButton_1 = (RadioButton)this.findViewById(R.id.radioButton1);
29&&&&&&&& mRadioButton_2 = (RadioButton)this.findViewById(R.id.radioButton2);&&&&&&
30&&&&&&&& mRadioButton_3 = (RadioButton)this.findViewById(R.id.radioButton3);&&&&&&
31&&&&&&&& mRadioButton_4 = (RadioButton)this.findViewById(R.id.radioButton4);&&&&&&
32&&&&&&&&
33&&&&&&&& //设置事件监听
34&&&&&&&& mRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
35&&&&&&&&&&&& public void onCheckedChanged(RadioGroup group, int checkedId) {
36&&&&&&&&&&&&&&&& if (checkedId == mRadioButton_2.getId()) {
37&&&&&&&&&&&&&&&&&&&& DisplayToast("正确答案:"+mRadioButton_2.getText()+",恭喜你,回答正确");
38&&&&&&&&&&&&&&&& } else {
39&&&&&&&&&&&&&&&&&&&& DisplayToast("回答错误!");
40&&&&&&&&&&&&&&&& }
41&&&&&&&&&&&& }
42&&&&&&&& });&&&&&
45&&&& //显示提示信息
46&&&& public void DisplayToast(String string) {
47&&&&&&&& Toast mToast = Toast.makeText(this, string, Toast.LENGTH_LONG);
48&&&&&&&& mToast.setGravity(Gravity.TOP, 0, 400);
49&&&&&&&& mToast.show();
  运行后可以看到,当用户选中正确答案后,会给出“正确答案:Linux,恭喜你,回答正确!”的提示信息,如图2所示。当用户选中错误答案后,则会给出“回答错误”的提示信息。如图3所示。
图2 回答正确
图3 回答错误
2.多项选择CheckBox
  多项选择与单项选择最重要的区别就是多项选择可以让用户选择一个以上的选项。
  在Android中,多项选择是通过CheckBox来实现的,为了确定用户是否选择了某一项,则需要对每一个选项进行事件监听。
  多项选择的实现方法和单项选择的实现方法大致相同。
  首先,在布局文件中定义一个TextView控件,用来显示问题。
  然后,再在布局文件中定义四个(根据需求而定)CheckBox控件,分别用来显示每一个选项。
  最后,在布局文件中定义一个Button控件,用于提交用户所选的选项(这个可以没有)。
  如下是实现一个多项选择demo的xml布局文件源代码:
多项选择xml源代码
&1 &LinearLayout xmlns:android="/apk/res/android"
&2&&&& xmlns:tools="/tools"
&3&&&& android:orientation="vertical"
&4&&&& android:layout_width="match_parent"
&5&&&& android:layout_height="match_parent" &
&7&&&& &!-- 题干 --&
&8&&&& &TextView
&9&&&&&&&& android:id="@+id/textview"
10&&&&&&&& android:layout_marginTop="10dp"
11&&&&&&&& android:layout_width="match_parent"
12&&&&&&&& android:layout_height="wrap_content"
13&&&&&&&& android:text="调查:你喜欢Android的原因是?"&&& &
14&&&& &/TextView&
16&&&& &!-- 选项 --&
17&&&& &CheckBox
18&&&&&&&& android:id="@+id/checkbox1"
19&&&&&&&& android:layout_width="match_parent"
20&&&&&&&& android:layout_height="wrap_content"
21&&&&&&&& android:text="无界限的应用程序"&&& &&&&&&&
22&&&& &/CheckBox&
24&&&& &CheckBox
25&&&&&&&& android:id="@+id/checkbox2"
26&&&&&&&& android:layout_width="match_parent"
27&&&&&&&& android:layout_height="wrap_content"
28&&&&&&&& android:text="应用程序是在平等的条件下创建的"&&& &&&&&&&
29&&&& &/CheckBox&
31&&&& &CheckBox
32&&&&&&&& android:id="@+id/checkbox3"
33&&&&&&&& android:layout_width="match_parent"
34&&&&&&&& android:layout_height="wrap_content"
35&&&&&&&& android:text="应用程序可以轻松地嵌入网络"&&& &&&&&&&
36&&&& &/CheckBox&
38&&&& &CheckBox
39&&&&&&&& android:id="@+id/checkbox4"
40&&&&&&&& android:layout_width="match_parent"
41&&&&&&&& android:layout_height="wrap_content"
42&&&&&&&& android:text="应用程序可以并行运行"&&& &&&&&&&
43&&&& &/CheckBox&
45&&&& &!-- 提交 --&
46&&&& &Button
47&&&&&&&& android:id="@+id/button"
48&&&&&&&& android:layout_width="100dp"
49&&&&&&&& android:layout_height="wrap_content"
50&&&&&&&& android:layout_marginLeft="110dp"
51&&&&&&&& android:text="提交"&&& &&&&&&
52&&&& &/Button&
54 &/LinearLayout&
  运行后的效果如图4所示。
图4 多项选择界面
  当然了,我们还需要在java代码中实现对用户的操作进行事件监听,并做出相应的响应。为此,我们需要为每一个CheckBox多项选择选项都设置一个事件监听器setOnCheckedChangeListener,并通过mCheckBox.isChecked()方法来判断该选项是否被选中(true表示被选中,false表示未选中)。此外,我们还可以通过一个全局变量checkedcount来统计当前有几个选项被选中,实现方法也很简单,当mCheckBox.isChecked()为true时令checkedcount++;当mCheckBox.isChecked()为false时令checkedcount--就可以了。最后,我们再为“提交”按钮设置一个监听器setOnClickListener,当用户点击“提交”时,显示一条总共选择了几项的提示信息。
  用上述方案实现多项选择demo的java源代码如下:
多项选择java源代码
& 1 package com.example.android_
& 3 import android.os.B
& 4 import android.view.G
& 5 import android.view.V
& 6 import android.view.View.OnClickL
& 7 import android.widget.B
& 8 import android.widget.CheckB
& 9 import poundB
&10 import android.widget.T
&11 import poundButton.OnCheckedChangeL
&12 import android.widget.TextV
&13 import android.app.A
&15 public class MainActivity extends Activity {
&17&&&& TextView mTextV&&&&&&&&&&&&&&&&&& //TextView对象,用于显示问题
&18&&&& CheckBox mCheckBox1;&&&&&&&&&&&&& //CheckBox对象,用于显示选项1
&19&&&& CheckBox mCheckBox2;&&&&&&&&&&&&& //CheckBox对象,用于显示选项2
&20&&&& CheckBox mCheckBox3;&&&&&&&&&&&&& //CheckBox对象,用于显示选项3
&21&&&& CheckBox mCheckBox4;&&&&&&&&&&&&& //CheckBox对象,用于显示选项4
&22&&&& Button mB&&&&&&&&&&&&&&&&&&&&&&&&&&&&& //Button对象,用于显示提交按钮
&24&&&& int checkedcount = 0;&&&&&&&&&&&&&&&&&&& //计数器,用于统计选中的个数
&26&&&& @Override
&27&&&& public void onCreate(Bundle savedInstanceState) {
&28&&&&&&&& super.onCreate(savedInstanceState);
&29&&&&&&&& setContentView(R.layout.activity_main);//加载布局文件
&30&&&&&&&&
&31&&&&&&&& //加载控件
&32&&&&&&&& mTextView = (TextView)this.findViewById(R.id.textview);
&33&&&&&&&& mCheckBox1 = (CheckBox)this.findViewById(R.id.checkbox1);
&34&&&&&&&& mCheckBox2 = (CheckBox)this.findViewById(R.id.checkbox2);&&&&&&&
&35&&&&&&&& mCheckBox3 = (CheckBox)this.findViewById(R.id.checkbox3);&&&&
&36&&&&&&&& mCheckBox4 = (CheckBox)this.findViewById(R.id.checkbox4);&&
&37&&&&&&&& mButton = (Button)this.findViewById(R.id.button);
&38&&&&&&&&
&39&&&&&&&& //选项1事件监听
&40&&&&&&&& mCheckBox1.setOnCheckedChangeListener(new OnCheckedChangeListener() {
&41&&&&&&&&&&&& public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
&42&&&&&&&&&&&&&&&& if (mCheckBox1.isChecked()) {
&43&&&&&&&&&&&&&&&&&&&& checkedcount++;
&44&&&&&&&&&&&&&&&&&&&& DisplayToast("你选择了:" + mCheckBox1.getText());
&45&&&&&&&&&&&&&&&& } else {
&46&&&&&&&&&&&&&&&&&&&& checkedcount--;
&47&&&&&&&&&&&&&&&& }
&48&&&&&&&&&&&& }
&49&&&&&&&& });
&51&&&&&&&& //选项2事件监听
&52&&&&&&&& mCheckBox2.setOnCheckedChangeListener(new OnCheckedChangeListener() {
&53&&&&&&&&&&&& public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
&54&&&&&&&&&&&&&&&& if (mCheckBox2.isChecked()) {
&55&&&&&&&&&&&&&&&&&&&& checkedcount++;
&56&&&&&&&&&&&&&&&&&&&& DisplayToast("你选择了:" + mCheckBox2.getText());
&57&&&&&&&&&&&&&&&& } else {
&58&&&&&&&&&&&&&&&&&&&& checkedcount--;
&59&&&&&&&&&&&&&&&& }
&60&&&&&&&&&&&& }
&61&&&&&&&& });
&62&&&&&&&&
&63&&&&&&&& //选项3事件监听
&64&&&&&&&& mCheckBox3.setOnCheckedChangeListener(new OnCheckedChangeListener() {
&65&&&&&&&&&&&& public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
&66&&&&&&&&&&&&&&&& if (mCheckBox3.isChecked()) {
&67&&&&&&&&&&&&&&&&&&&& checkedcount++;
&68&&&&&&&&&&&&&&&&&&&& DisplayToast("你选择了:" + mCheckBox3.getText());
&69&&&&&&&&&&&&&&&& } else {
&70&&&&&&&&&&&&&&&&&&&& checkedcount--;
&71&&&&&&&&&&&&&&&& }&&&&&&&&&&&
&72&&&&&&&&&&&& }
&73&&&&&&&& });
&74&&&&&&&&
&75&&&&&&&& //选项4事件监听
&76&&&&&&&& mCheckBox4.setOnCheckedChangeListener(new OnCheckedChangeListener() {
&77&&&&&&&&&&&& public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
&78&&&&&&&&&&&&&&&& if (mCheckBox4.isChecked()) {
&79&&&&&&&&&&&&&&&&&&&& checkedcount++;
&80&&&&&&&&&&&&&&&&&&&& DisplayToast("你选择了:" + mCheckBox4.getText());
&81&&&&&&&&&&&&&&&& } else {
&82&&&&&&&&&&&&&&&&&&&& checkedcount--;
&83&&&&&&&&&&&&&&&& }
&84&&&&&&&&&&&& }
&85&&&&&&&& });
&86&&&&&&&&
&87&&&&&&&& //”提交“按钮事件监听
&88&&&&&&&& mButton.setOnClickListener(new OnClickListener() {
&89&&&&&&&&&&&& public void onClick(View v) {
&90&&&&&&&&&&&&&&&& DisplayToast("谢谢参与,你一共选择了" + checkedcount + "项!");
&91&&&&&&&&&&&& }
&92&&&&&&&& });
&95&&&& //显示提示信息
&96&&&& public void DisplayToast(String string) {
&97&&&&&&&& Toast mToast = Toast.makeText(this, string, Toast.LENGTH_LONG);
&98&&&&&&&& mToast.setGravity(Gravity.TOP, 0, 450);
&99&&&&&&&& mToast.show();
100&&&& }&
  运行后可以看到,当用户选择了某一个选项后,会给出类似“你选择了:应用程序可以轻松地嵌入网络”的提示信息,如图5所示。当用户点击“提交”按钮后,会给出类似“谢谢参与,你总共选择了2项”的提示信息,如图6所示。
&图5 选择选项效果
&图6 提交选项效果
3.定制自己的单项选择RadioButton式样
  Android提供的单项选择RadioButton式样比较单一,如何来定制自己想要的单项选择RadioButton式样呢?下面给出一个简单的实现案例。
  我们知道,Android提供的单项选择RadioButton式样,有三点最基本的特性:
  第一,RadioButton有两种状态,一种是未选中下的置灰状态,另一种是选中下的高亮状态,且两种状态互斥。
  第二,RadioButton间存在互斥性,即仅能选中其中的某一个选项。
  第三,能够判断出当前用户选择的是哪一个RadioButton选项。
  所以,我们自己定制的单项选择RadioButton式样至少也应该具备以上的三点特性。
3.1特性一的实现
  特性一的实现并不复杂,我们可以使用两张不同的图片来分别表示RadioButton的两种状态(选中和未选中),而选中和未选中的状态则可以通过android:state_checked属性来设置。具体可以通过在工程的res/drawable目录下新建一个radiostyle.xml文件来实现,radiostyle.xml文件的源代码如下,其中button_ok是选中状态下要显示的图片,button_ng是未选中状态下要显示的图片。
radiostyle.xml源代码
&1 &?xml version="1.0" encoding="utf-8"?&
&2 &selector xmlns:android="/apk/res/android"&
&4&&&& &!-- 未选中状态 --&
&5&&&& &item
&6&&&&&&&& android:state_checked="false"
&7&&&&&&&& android:drawable="@drawable/button_ng"&&& &
&8&&&& &/item&
10&&&& &!-- 选中状态 --&
11&&&& &item
12&&&&&&&& android:state_checked="true"
13&&&&&&&& android:drawable="@drawable/button_ok"&&& &
14&&&& &/item&
16 &/selector&
3.2特性二的实现
  要实现RadioButton选项间的互斥性,可以通过mRadioButton.setChecked()方法来实现,当某一选项为true时,将其余选项置为false即可。
3.3特性三的实现
  要判断用户选中的是哪一个选项,可以通过为每一个RadioButton按钮设置一个setOnClickListener监听器来实现。
3.4实例效果
  在本实例中,定制了一个自己的单项选择RadioButton式样,并且实现RadioButton式样的上述三点最基本的特性,达到了和1.单项选择RadioButton中的所举例子同样的运行效果。运行效果分别如图7、图8、图9所示。
图7 自定义单项选择式样
图8 回答正确
图9 回答错误

我要回帖

更多关于 单项选择题 的文章

 

随机推荐