Android学习--GeoQuiz项目
来源:互联网 发布:网络打印机维修 编辑:程序博客网 时间:2024/06/05 15:12
实验要求:
开发环境搭建:建立一个HelloWorld程序,在模拟器上运行。跟随老师完成GeoQuiz项目。
实验步骤:
1.新建项目
2.布局代码
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:orientation="vertical" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="24dp" android:text="@string/question_text" /> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content"> android:orientation="horizontal" <Button android:id="@+id/true_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/true_button" /> <Button android:id="@+id/false_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/false_button" /> </LinearLayout></LinearLayout>3.改下string
<resources><string name="app_name">New3</string><string name="question_text">武汉是湖北省省会么</string><string name="true_button">是的</string><string name="false_button">不是</string><string name="correct_toast">回答正确</string><string name="incorrect_toast">回答错误</string></resources>
4.main函数
package com.example.pc.new3;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.view.Menu;import android.view.MenuItem;import android.view.View;import android.widget.Button;import android.widget.Toast;import com.example.pc.new3.R;public class Main extends AppCompatActivity { private Button mTrueButton; private Button mFalseButton; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mTrueButton = (Button) findViewById(R.id.true_button); mTrueButton.setOnClickListener( new View.OnClickListener(){ public void onClick(View v){ Toast.makeText(getApplicationContext(), R.string.correct_toast, Toast.LENGTH_SHORT).show(); } }); mFalseButton = (Button) findViewById(R.id.false_button); mFalseButton.setOnClickListener( new View.OnClickListener(){ public void onClick(View v){ Toast.makeText(getApplicationContext(), R.string.incorrect_toast, Toast.LENGTH_SHORT).show(); } }); }}5.完成截图
点击“是的”
点击“不是”
0 0
- Android学习--GeoQuiz项目
- Android编程权威指南--GeoQuiz笔记及拓展
- Android编程权威指南——GeoQuiz 学习体会
- GeoQuiz应用
- android开发入门(一)android studio上的第一个应用GeoQuiz
- GeoQuiz的个人见解
- Android源码项目学习
- android学习项目
- Android项目学习
- Android项目学习有感
- android mvp学习项目
- GeoQuiz 第二章挑战练习代码
- android开源项目学习
- android开源项目学习
- Android开源项目学习
- android开源项目学习
- Android:项目实战学习笔记
- Android学习.0(Android项目目录结构)
- 干货分享!DevExpressv16.2最新版演示示例等你来收!(下)
- Darwin做直播时对ReflectorSession引用数的控制
- 控制台录音生成wav文件
- cocos 跳坑记录之Layer的锚点设置
- three.js加载obj模型 键盘控制模型局部动作
- Android学习--GeoQuiz项目
- 剑指offer 31. 连续子数组的最大和
- 浅析JS中的 map, filter, some, every, forEach, for in, for of 用法总结
- 使用AutoResetEvent信号实现生产者消费者队列
- TPLINK渗透
- java中对数组的操作
- lua学习之table类型
- js闭包详解
- opencv 垂直投影分割字符