博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Android开发初体验
阅读量:7046 次
发布时间:2019-06-28

本文共 1581 字,大约阅读时间需要 5 分钟。

第一个Androd应用-GeoQuiz,它能给出一道道地理问题,用户点击TRUE或FALSE按钮来回答屏幕上的问题,GeoQuiz及时做出反馈,首先我们来看看它完成后的样子

1.首先我们创建一个Android项目

接下来SDK的选择最低版本是4.4我选择的的是7.0,然后继续Next

选择Empty Activity,继续Next

命名activity的子类为Quizactivity,点击finsh.这样就完成了项目的创建

 

2.接下来就是源码,在activity_quiz.xml添加组件

 

 然后是string.xml

GeoQuiz
Canberra is the capital of Australia.
The Pacific Ocean is larger than the Atlantic Ocean.
The Suez Canal connects the Red Sea and the Indian Ocean.
The source of the Nile River is in Egypt.
The Amazon River is the longest river in the Americas.
Lake Baikal is the world\'s oldest and deepest freshwater lake.
True
False
Next
Correct!
Incorrect!
Are you sure you want to do this?
SHOW ANSWER
CHEAT!
Cheating is wrong.
NEXT
PTEV

 和activity_cheat.xml

 3.创建数组对象,与Textview和button交互,对用户的回答做出反应 
 
 

 

 
 
  4.设置监听器@Override
public void onClick(View v) {
if (mAnswerIsTrue) {
mAnswerTextView.setText(R.string.true_button); }
else {
mAnswerTextView.setText(R.string.false_button);
}
setAnswerShownResult(true);
}

 

转载于:https://www.cnblogs.com/haiou123/p/7537791.html

你可能感兴趣的文章
团队冲刺第五天
查看>>
js作用域和作用域链
查看>>
ERP流程图
查看>>
10.29 A
查看>>
LOVE2D-03-完整的LOVE2D程序
查看>>
使用safe-rm替代rm
查看>>
Codeforces Round #526 (Div. 1)
查看>>
NX签名//NXOpen VB.Net / C# Sign
查看>>
Mac下安装nginx
查看>>
<转>IOS多线程
查看>>
微信服务号、订阅号和企业号的差别(运营和开发两个角度)
查看>>
AOP之AspectJ
查看>>
SHELL里执行HIVE导出文件处理成CSV文件
查看>>
Python菜鸟之路:Django 路由补充1:FBV和CBV - 补充2:url默认参数
查看>>
【转】生活感悟
查看>>
【leetcode】965. Univalued Binary Tree
查看>>
第十五周学习报告
查看>>
tomcat用户设置
查看>>
LINQ实现行列转换
查看>>
PHP最全笔记(五)(值得收藏,不时翻看一下)
查看>>