有没有魔方高手制霸技帮忙看下我的魔方是不是一装错了?

您所在位置: &
&nbsp&&nbsp&nbsp&&nbsp
App Inventor的应用.pdf41页
本文档一共被下载:
次 ,您可免费全文在线阅读后下载本文档
文档加载中...广告还剩秒
需要金币:100 &&
App Inventor的应用.pdf
你可能关注的文档:
··········
··········
杭州市源清中学兴趣特长类选修教材
App Inventor 的应用
赵建波 编著
杭州市源清中学
1.本教材著作权归教材作者所有,未经作者授权,任何组织或个人不得以任何形式对本教材
进行出版、发行。
2 .本教材由作者授权在浙江教育资源网独家发布,其他组织和个人不得进行转载、发布。
3.本教材供浙江省普通高中选用,全省普通高中学校可以通过浙江教育资源网实名下载本教
材的电子版及相关教育资源,允许并仅供在本校范围内用于选修课教学。
4 .本教材存在的疏漏、错误之处敬请批评指正,欢迎相关专家、老师与作者联系,共同参与
本教材的研究和完善工作。
Android 是当今应用最广泛的智能手机平台,也是最受欢迎的智能手机系统之一,Android 的开发
虽然能锻炼逻辑思维与开发能力,但其开发具有一定的难度。
App Inventor 是基于浏览器的编程工具,以可视化的积木式模块化编程,将复杂的编程简单化,从
开发到部署应用只需要几分钟,让学生轻松、愉快地进入移动应用软件开发大门,极大地提升了学生
学习的兴趣。
本课程主要介绍的是AppInventor 2.0 版本,书中所涉及的内容包括App Inventor 的开发环境搭建、
用户界面开发、基础组件介绍、指今应用等。共分为3 章。第1 章介绍App Inventor 的简介,重点介
绍App Inventor 环境搭建和App Inventor 开发界面;第2 章详细介绍了App Inventor 的Basic 组件,在
这过程也附加了一些编程语法等。第3 章介
正在加载中,请稍后...应用程序发明家(app inventor) QuizMe 项目学习 - 程序员的每日问题汇总 - ITeye技术网站
博客分类:
准备工作:下载实例图片
使用组件设计为QuizMe创建接口。你什么时候完成,它应该类似于下面所示的屏幕快照(也有更详细的说明快照)。
要创建这个接口,首先加载图片下载到你的项目。点击Add按钮,并选择一个地区的媒体下载的文件(例如,Larsenberra.jpg)。然后做同样的其他三个图像。    接下来,创建以下组件从调色板中通过拖拽到查看器。
Component Type
Palette Group
What you'll name it
Purpose of Component
The picture part of the question
QuestionLabel
Displays the current question
HorizontalArrangement
Screen Arrangement
HorizontalArrangement1
Organizes the AnswerPrompt and Text
AnswerPromptLabel
Text prompting for an anwer
AnswerText
User will enter answer here.
RightWrongLabel
Correct/Incorrect is displayed here.
HorizontalArrangement
Screen Arrangement
HorizontalArrangement2
Organizes the AnswerButton and NextButton
AnswerButton
User clicks to submit an answer
NextButton
User clicks to proceed to the next answer
设置组件的属性如下所述:
Set its Picture property to "Larsenberra.jpg". This is the first picture that should appear.
QuestionLabel
Change Text property to "question"
AnswerPromptLabel
Change Text property to "Enter Answer:". On the Viewer screen, move this label intoHorizontalArrangement1.
AnswerText
Change Hint to "please enter an answer". On the Viewer screen, move AnswerText intoHorizontalArrangement1.
AnswerButton
Change Text property to "Submit". On the Viewer, move the button intoHorizontalArrangment2.
NextButton
Change Text property to "Next". Move the button into HorizontalArrangement2.
RightWrongLabel
Change Text property to "correct/incorrect".
打开块编辑器来添加行为的应用。首先,您将定义两个列表变量,QuestionList举行的问题列表,AnswerList持有相应的答案列表。    定义两个变量列表,您需要以下内容块:
Block Type
def variable
Definitions
Defines the QuestionList variable (rename it)
def variable
Definitions
Defines the AnswerList variable (rename it)
make a list
Used to insert the items of the QuestionList
text (3 of them)
The actual questions
make a list
Used to insert the items of the AnswerList
text (3 of them)
The actual answers
您创建全局变量通过拖拽在def可变块从定义抽屉,双击默认的名字“变量”来改变它的名字。def的可变块有一个位置变量的初始值。变量可以代表一个数字或文字,甚至是一个列表,您可以插入列个清单块到变量定义。   
 这个街区应该看起来像这样:
每当用户单击NextButton继续通过测验,这个应用程序需要记住,问题就在。在程序设计中,记住一些东西,您定义一个新的变量。在这种情况下,应用程序需要记住当前问题的数字——该指数为QuestionList列表。
要创建变量currentQuestionIndex,您需要以下内容块:
Block Type
def variable
Definitions
Defines the currentQuestionIndex variable (rename it)
number (1)
Set the initial value of currentQuestionIndex to 1
The blocks should look like this:
首先,你会忽略这些答案,只是工作行为序列通过问题。期望的行为如下:当应用程序启动时,第一个问题应该出现在标签QuestionLabel命名。当用户单击NextButton,第二个问题应该出现。当用户单击再次,第三个应该出现。当最后一个问题是达成,单击NextButton应该导致第一个问题再次出现在theQuestionLabel。
与应用程序发明家,你选择特定项的列表中选择列表项的块。块要求您指定列表和一个指数——一个列表中的位置。如果一个列表有三个项目,索引1、2和3都是有效的。
对于QuizMe,当应用程序启动时,应用程序应该选择列表中的第一个问题,在QuestionLabelcomponent显示它。
对于这个应用程序初始化行为,您需要以下内容块:
Block Type
Screen1.Initialize
When the app begins, this event-handler is triggered.
set QuestionLabel.Text to
QuestionLabel
Need to put the first question in QuestionLabel
select list item
Need to select the first question from QuestionLabel
global QuestionList
My Definitions
The list to select from
number (1)
Select the first question by using an index of 1
这个街区应该看起来像这样:
Screen1的。初始化事件时触发应用程序开始。第一项QuestionList的变量选择和放置在QuestionLabel.Text。因此,当应用程序开始,用户将看到的第一个问题。
测试这个行为。单击重启手机应用程序(或连接的电话如果没有连接)。什么东西出现在电话吗?如果你创建了QuestionList如上所述,QuestionList的第一项,“谁投一个完美的游戏世界系列吗?“,应该出现在QuestionLabel。
现在项目NextButton的行为。你已经定义了currentQuestionIndex记住用户的问题上。当NextButton被单击时,应用程序需要增加这个变量,例如,改变它从1到2个或2到3等等,然后使用结果值来选择新“当前”的问题。对于这种行为,您需要以下内容块:
Block Type
NextButton.Click
NextButton
When user clicks Next, this event-handler is triggered.
set currentQuestionIndex to
My Definitions
Need to put the first question in QuestionLabel
Used to increment currentQuestionIndex
global currentQuestionIndex
My Definitions
New value will be old value + 1
number (1)
For the + 1
set QuestionLabel.Text to
QuestionLabel
Need to display the next question here
select list item
Need to select the first question from QuestionList
global QuestionList
My Definitions
Plug into list slot of call select list item
global currentQuestionIndex
My Definitions
Plug into index slot of call select list item, we want nth item
这个拼图应该看起来像这样:
第一行的拼图currentQuestionIndex增加变量。如果currentQuestionIndex有一个1,它就变成了2。如果它有一个2,它就变成了3,等等。一旦currentQuestionIndex变量已经改变,应用程序使用它来选择“当前”的问题。
回想一下,在Screen.Initialize事件句柄,这个应用程序选择第一个问题来显示:
当NextButton被单击时,应用程序不选择列表中的第一项,或者第二或者第三次,它选择这currentQuestionIndex项目.
这个街区是在从右到左的方式执行。这个应用程序首先评估指标参数的选择列表项,它是currentQuestionIndex的变量。这个数字是存储在currentQuestionIndex用作指数当选择列表项目执行。
当NextButton第一次点击,增加currentQuestionIndex块将从1到2,那么应用程序将从QuestionList选择第二个项目,“谁投第一场完全比赛2010
?”。NextButton第二次点击,currentQuestionIndex会设置2到3,程序会选择列表中的第三问题,“谁投第一场完全比赛的现代吗?”
测试这个行为。测试NextButton的行为,看看这个应用程序是否正常工作为止。为了测试,扮演角色的用户并单击NextButton打电话。做手机显示的第二个问题,“谁投第一场完全比赛的2010吗?“它应该,和第三个问题应该出现当你点击NextButton再次。如果这是工作,拍拍自己的迅速恢复,然后继续。    尝试再次单击NextButton(第三次)。您应该看到一个错误:“试图获得第四项列表的长度为3”。这个应用程序有一个bug,你知道是什么问题?
问题是,它的应用程序总是增加currentQuestionIndex变量当NextButton点击。当currentQuestionIndex已经3和用户单击NextButton,这个应用程序更改currentQuestionIndex
3到4,然后调用选择列表项目获得currentQuestionIndex-th,或在这种情况下,第四项。因为只有三个项目在变量QuestionList,Android抱怨。    这个应用要做的是问一个问题——先检查条件——当NextButton被单击,并执行不同的块dependending在答案。问这个问题的一个方法是问,“是变量currentQuestionIndex已经3
?“如果答案是肯定的,你应该设定currentQuestionIndex回到0,因此用户被送回到第一个问题。    您需要以下块:
Block Type
if test then-do
To ask if user is on last question
to test if currentQuestionIndex is 3
global currentQuestionIndex
My Definitions
3 is number of items in the list
set currentQuestionIndex to
My Definitions
set to 0 to go back to first question
set to 0 because next blocks will increment to 1
The modified NextButton.Click event-handler should look like this:
当NextButton被单击时,应用程序首先检查是否有一个3
currentQuestionIndex在它。如果是这样,currentQuestionIndex是重新设置为0,这样当1添加到它下面的街区,这将是1和测验将循环回到显示第一个问题。注意,只有块嵌入在如果测试然后做块都依赖于条件——增量和QuestionLabel设置。文本块的执行在所有条件。
测试这个行为。因为变量如currentQuestionIndex是隐藏的,他们常常是在一个程序错误的来源。幸运的是,App
Inventor提供了一种方法来做这样的隐藏变量在测试期间的透明。具体地说,App
Inventor可以让你“看”如何改变一个变量的值作为一个应用的进展。在这个测试中,右键单击currentQuestionIndex
def块在街区编辑器并选择观看。然后选择重启手机应用程序,然后将显示def块和一个手表盒显示的初始值currentQuestionIndex(这应该是1):
现在拿起电话并单击NextButton。第二个问题,“谁把最近的完美的游戏在大联盟吗?“应该出现在QuestionLabel打电话,像以前一样。在App
Inventor屏幕,2应该出现在currentQuestionIndex记忆细胞:
当你再次单击,第三个问题应该出现在电话和3应该出现在记忆细胞。如果你再次单击,1应该出现在currentQuestionIndex和在电话上的第一个问题。
接下来,您将修改应用程序以使它容易添加和删除元素的列表。你会重写块,因此,他们将继续工作,任何列表,而不只是一个恰好三个项目。首先,添加第四个问题的回答,AnswerList
QuestionList和另一个。这个街区应该看起来像这样:
修改后的应用程序测试。单击NextButton好几次。你应该看到,第四个问题再也不会现身,无论有多少次你点击Next。
修改后的应用程序测试。单击NextButton好几次。你应该看到,第四个问题再也不会现身,无论有多少次你点击Next。
你可以改变数字3到4,这个应用程序将再次正常工作。这个解决方案的问题在于,每次修改问题和答案,你也要记得做这种改变。这种依赖关系在计算机程序往往会导致错误,特别是作为一个应用生长在复杂性。最好是设置程序,它将工作无论多少的问题存在。这种普遍性是更重要的,当你正在与列表动态变化,例如,一个测试应用程序,允许用户添加新的问题。    更好的解决方案是问这个问题在一个更普遍的方式。你真的想知道如果当前问题用户仍在——currentQuestionIndex的价值——是一样大QuestionList中项目的数量。如果程序问这个问题在这个更通用的方式,它将工作甚至当你添加到null
Block Type
length of list
asks how many items are in QuestionList
global QuestionList
My Definitions
put into list slot of length of list
Your NextButton.Click event-handler should now appear as:
如果现在的测试比较了currentQuestionIndex
QuestionList的长度。所以,如果currentQuestionIndex有一个4,QuestionList的长度是4,那么currentQuestionIndex将被设置为0(然后1增量操作后在第一排块后,如果)。注意,因为块不再引用3或任何特定的大小,这种行为将工作不管列表项的多少。
测试修改后的行为。当你点击NextButton,并应用程序现在序列通过四个问题,移动到第一个后的第四种吗?
当前的应用程序显示了相同的图像,不管什么问题问。你可以改变这样一个图像用于修饰或说明每个问题出现在NextButton点击。早些时候,你增加了四个图片作为媒体项目。现在,您将创建一个列表,PictureList第三的名字,作为其项目的图像文件。和你theNextButton将修改。单击事件句柄来切换每个图片的时间。    首先,创建一个PictureList和初始化它的名称图像文件。确保名称是完全一样的文件的名称中被加载到媒体的项目。下面是这个块PictureList应该:
接下来,您需要修改NextButton。单击事件句柄,以便它修改图片根据用户仍在什么问题。如果你设置图像。图片财产到一个文件的名字的影像时,已经被加载,图像将会出现。NextButton修改。单击,您需要以下内容块:
Block Type
set Image1.Picture to
set this to change the picture
select list item
need to select the picture corresponding to current question
global PictureList
My Definitions
select a file name from this list
global currentQuestionIndex
My Definitions
select the currentQuestionIndex-th item
这是块如何应该:
这个currentQuestionIndex作为索引QuestionList和currentQuestionIndex是1,这个应用程序选择第一个问题和第一个图像。当currentQuestionIndex是2,这个应用程序选择第二个问题和第二幅。当然这个计划取决于列表被同步,事实上他们是。例如,第一张图片,LarsenBerra。jpg,是一幅唐拉森,唐拉森是第一个问题的答案,“谁投一个完美的游戏世界系列吗?“测试修改后的行为。做一个不同的图像看起来每一次你点击NextButton吗?
 评估答案
接下来,您将添加块报告用户是否已经回答了一个问题正确与否。用户输入答案,然后单击AnswerButton
AnswerText。应用程序必须比较用户输入的答案“当前”问题,使用一个ifelse块来检查。这个RightWrongLabel应该修改报告是否答案是正确的。您需要以下块这种行为:
Block Type
AnswerButton.Click
AnswerButton
the behavior is triggered when user clicks the AnswerButton
if answer is correct, do one thing, else do another
to ask if answer is correct
AnswerText.Text
AnswerText
the user's answer is in this textbox
select list item
to select the current answer from AnswerList
global AnswerList
My Definitions
The list to select from
global currentQuestionIndex
My Definitions
the question number (and answer number) the user is on
set RightWrongLabel.Text to
RightWrongLabel
report the answer here
text block "correct"
if answer is right
set RightWrongLabel.Text to
RightWrongLabel
report the answer here
text block "incorrect"
if answer is wrong
The blocks should look like this:
测试的ifelse写道,“是用户的答案(AnswerText.Text)等于currentQuestionIndex-th项目在theAnswerList吗?“如果currentQuestionIndex是1,该应用程序将比较用户的答案与第一项在AnswerList,”唐拉森”。如果currentQuestionIndex是2,该应用程序将比较用户的答案与列表中的第二个答案,”达拉斯布莱登”,等等。如果测试结果是积极的,然后做块的执行和RightWrongLabel设置为“正确!”。如果测试是假的,其他块的执行和RightWrongLabel设置为“不正确的”。    
修改后的应用程序测试。尝试回答的问题之一。它应该报告你是否回答这个问题完全一样AnswerList中指定。试验与一个正确和错误的答案(因为文本相比,测试是大小写敏感)。    
单击NextButton和回答第二个
Block Type
set RightWrongLabel.Text to
RightWrongLabel
the label to blank out
text (blank)
When Next is clicked, erase old answer critique
set AnswerText.Text to
AnswerText
the user's answer from previous question
text (blank)
When Next is clicked, erase old answer
这个拼图应该看起来像这样:
当NextButton点击,用户移动到下一个问题,所以前两行中的事件句柄清空RightWrongLabel和AnswerText。   
 测试这个行为。回答问题,并单击Submit,然后单击NextButton。做你以前的回答和应用批判消失?
QuizMe! Final Version:
方案的最终版本应用程序通过选择包电话|条形码从组件设计菜单。当条码出现,使用条形码扫描仪,在你的手机下载和安装这个应用程序。    
变化    
一旦你得到一个测验工作,你可能想要探索一些变化。
 而不是仅仅显示图像对于每个问题,试着声音剪辑或短视频。与声音,你可以把你的测试应用程序到一个名称,调优应用程序。  
这个测试是非常严格的条件被接受为一个有效的回答。有许多方法来修改这个。一种方法是使用文本。包含块看看用户的答案是包含在实际的回答。另一种方法是提供多个回答每个问题,检查通过迭代(使用foreach)通过它们来看看任何匹配。  
变换测验,所以这是多项选择题的答案列表需要
浏览: 26469 次
来自: 太原
赞! 请问楼主
“工作中使用过的struts2-jquery ...
我在使用grid的时候,出现中文乱码啊。。。就是传值到后台的时 ...&&&&人人都能开发安卓App--App&Inventor2应用开发实战(国内首本App&I...
自营订单满39元(含)免运费
不足金额订单收取运费5元起
邀请好友参加吧
版 次:5页 数:字 数:印刷时间:日开 本:12k纸 张:胶版纸印 次:1包 装:平装是否套装:否国际标准书号ISBN:0所属分类:&&&
下载免费当当读书APP
下载当当读书APP,免费阅读万本电子书。
本商品暂无详情。

我要回帖

更多关于 魔方高手简介 的文章

 

随机推荐