第一个程序的实现的最终功能是:

点击"正确"或者"错误"会得到一个是否正确的提示。

直接上效果图。

 

 

此次涉及代码编写的文件有4个:

package com.Kyleapp2;

 

import android.support.v7.app.ActionBarActivity;

import android.os.Bundle;

import android.view.Menu;

import android.view.MenuItem;

import android.view.View;

import android.widget.Button;

import android.widget.Toast;

 

 

public
class MainActivity<QuizActivity> extends ActionBarActivity {

 

    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);

mFalseButton = (Button)findViewById(R.id.false_button);

mTrueButton.setOnClickListener(new View.OnClickListener() {

    @Override

    public
void onClick(View v) {

    // Does nothing yet, but soon!

        Toast.makeText

        (MainActivity.this, R.string.correct_toast,

        Toast.LENGTH_SHORT).show();

    }

});

 

mFalseButton.setOnClickListener(new View.OnClickListener() {

    @Override

    public
void onClick(View v) {

    // Does nothing yet, but soon!

        Toast.makeText(MainActivity.this, R.string.incorrect_toast,

                Toast.LENGTH_SHORT).show();

    }

});

}

 

 

@Override

public
boolean onCreateOptionsMenu(Menu menu) {

// Inflate the menu; this adds items to the action bar if it is present.

getMenuInflater().inflate(R.menu.main, menu);

return
true;

}

 

@Override

public
boolean onOptionsItemSelected(MenuItem item) {

// Handle action bar item clicks here. The action bar will

// automatically handle clicks on the Home/Up button, so long

// as you specify a parent activity in AndroidManifest.xml.

int id = item.getItemId();

if (id == R.id.action_settings) {

return
true;

}

return
super.onOptionsItemSelected(item);

}

}

 

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:tools="http://schemas.android.com/tools"

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" />

 

<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>

 

 

 

*/

public
static
final
int abc_shareactionprovider_share_with_application=0x7f0a000b;

public
static
final
int action_settings=0x7f0a000f;

public
static
final
int app_name=0x7f0a000d;

public
static
final
int correct_toast=0x7f0a0012;

public
static
final
int false_button=0x7f0a0011;

public
static
final
int incorrect_toast=0x7f0a0013;

public
static
final
int question=0x7f0a000e;

public
static
final
int true_button=0x7f0a0010;

<?xml
version="1.0"
encoding="utf-8"?>

<resources>

 

<string
name="app_name">App2</string>

<string
name="question">贵州是个美丽的地方?</string>

<string
name="action_settings">Settings</string>

 

<string
name="true_button">正确</string>

<string
name="false_button">错误</string>

 

<string
name="correct_toast">Correct!</string>

<string
name="incorrect_toast">Incorrect!</string>

 

</resources>

 

布局预览

 

总结:

    此过程,只需要关注以上四个文件。一下是它们各自的作用。

相当于我们的主程序文件,也就是"main.c"

显示的字符串信息在这里

 

程序界面控件在这里

 

这个不需要我们管,系统自动生成的

Android程序初体验的更多相关文章

  1. wxWidgets刚開始学习的人导引(3)——wxWidgets应用程序初体验

    wxWidgets刚開始学习的人导引全文件夹   PDF版及附件下载 1 前言2 下载.安装wxWidgets3 wxWidgets应用程序初体验4 wxWidgets学习资料及利用方法指导5 用wx ...

  2. 微信小程序初体验,入门练手项目--通讯录,部署上线(二)

    接上一篇<微信小程序初体验,入门练手项目--通讯录,后台是阿里云服务器>:https://www.cnblogs.com/chengxs/p/9898670.html 开发微信小程序最尴尬 ...

  3. wxWidgets初学者导引(3)——wxWidgets应用程序初体验

    wxWidgets初学者导引全目录   PDF版及附件下载 1 前言2 下载.安装wxWidgets3 wxWidgets应用程序初体验4 wxWidgets学习资料及利用方法指导5 用wxSmith ...

  4. 【尝新】微信小程序初体验

    文档地址:https://mp.weixin.qq.com/debug/wxadoc/dev/?t=1474644089434 根据文档地址中下载微信开发工具后,按照文档指引可以创建一个快速体验的小d ...

  5. .net程序员的android studio 初体验 (环境设置2022年10月)

      很久以前用DevExtreme写的一个Hybird APP要添加蓝牙打印功能,但是用来打包APP的phonegap被adobe关闭了,所以,只能自己用cordova去打包安卓APP,不得已,研究了 ...

  6. Android RecyclerView初体验

    很早之前就听说过RecyclerView这个组件了,但一直很忙没时间学习.趁着周末,就花了一天时间来学习RecyclerView. 准备工作 在Android Studio里新建一个Android项目 ...

  7. 微信小程序初体验(上)

    版权声明:本文由练小习原创文章,转载请注明出处: 文章原文链接:https://www.qcloud.com/community/article/204 来源:腾云阁 https://www.qclo ...

  8. Win手机安卓程序初体验

    老大说快看博客园,Windows手机可以装安卓程序了. 啊,真的么?可以在我的撸妹1520上愉快的玩COC了么?我还可以愉快的看小说,不对,是听小说,哈哈,安卓君的三千万程序兵,等着老夫来一一临幸你们 ...

  9. wx小程序初体验

    小程序最近太火,不过相比较刚发布时,已经有点热度散去的感觉,不过这不影响我们对小程序的热情,开发之前建议通读下官网文档,附链接:https://mp.weixin.qq.com/debug/wxado ...

随机推荐

  1. AI—家庭组机器人平台环境配置,高级人工智能实验总结

    首先说一下我的环境:Ubuntu 12.04 32bit,  gcc 4.6.3 一,安装boost 1.48,建议用这个版本的,不然会出现兼容性问题 步骤: 其实在ubuntu下,可以用一下命令直接 ...

  2. JAVA 数组的常用操作

    目录: 声明数组: 初始化数组: 查看数组长度: 遍历数组: int数组转成string数组: 从array中创建arraylist: 数组中是否包含某一个值: 将数组转成set集合: 将数组转成li ...

  3. rpm 命令|rpm 安装|rpm 卸载|rpm 使用|rpm 删除

    在Linux操作系统中,有一个系统软件包,它的功能类似于Windows里面的“添加/删除程序”,但是功能又比“添加/删除程序”强很多,它就是Red Hat Package Manager(简称RPM) ...

  4. 1.1-1.4 hadoop调度框架和oozie概述

    一.hadoop调度框架 Linux Crontab Azkaban https://azkaban.github.io/ Oozie http://oozie.apache.org/ Zeus(阿里 ...

  5. Identity Server 4 原理和实战(完结)_Authorization Code Flow 实例

    Code在Oauth2.0和OpenId Connect里面分别叫做不同的名字 OAuth只介绍了如何授权.没有介绍如何身份认证. OpenId Connect:既规定了怎么授权,也规定了怎么身份认证 ...

  6. 洛谷 - P1582 - 倒水 - 位运算

    https://www.luogu.org/problemnew/show/P1582 要求用最少的瓶子,那肯定不能有两个一样的瓶子,否则合并更优. 枚举其二进制位,每次加上lowbit,将最后一个1 ...

  7. HDU2444 【二分图判定+最大匹配】

    套模板很好的题? #include<bits/stdc++.h> using namespace std; const int N=2e2+10; const int M=4e4+10; ...

  8. Codeforces712C【贪心】

    看了这篇.. http://blog.csdn.net/queuelovestack/article/details/52503162 直接就是从小到大,那么每次按最大的递增顺序上去,就是了. 因为每 ...

  9. [Swift]堆栈Stack:检索最小元素时间复杂度O(1)

    ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...

  10. Peptidomics analysis of milk protein-derived peptides
released over time in the preterm infant stomach
 (文献分享一组-陈凌云)

    题目:Peptidomics analysis of milk protein-derived peptides
released over time in the preterm infant st ...