又是新的一年开学季,这学期开始学习Android应用软件。

我的第一个Android应用程序是一个非常非常简便的加法计算,创建项目的过程就不多说了。

创建的项目会生成许多的文件(如下图),但是我现在只运用了3个文件,一个是res下的layout下的页面布局activity_main.xml文件和values下的string.xml,和src根目录下的后台Java文件MainActivity.java。

在string.xml下是页面中需要用到的一些文本和字符,默认的信息是Hello world!,我们可以在string.xml中添加自己需要的文本和字符信息(如下左图),当自己添加的信息被保存的时候,这些信息就会自动向gen目录下的R.java文件注册自己添加的信息(如下右图)。

                          

在activity_main.xml中我们可以自己设置页面的布局方式,并调用string.xml中的文本和字符信息,我自己设置的简单页面如图所示

    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    
            android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">


            android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:inputType="text"
        android:id="@+id/first"
        />
    
            android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/jiahao" />
    
            android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:inputType="text"
        android:id="@+id/second"/>
    
            android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/denghao"/>
    
            android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:inputType="text"
        android:id="@+id/third"/>
    
   

    
            android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/jisuan"
        android:id="@+id/js"/>
    


这样我们就可以对这个页面进行事务的处理,在Java文件中编写后台程序,我们要对变量进行注册(如下图),如果不对变量进行注册你的程序可能什么问题,但是当发布到APP虚拟机时可能就会提示一段英文信息,开始我也是没对按钮进行注册,发布到虚拟机时总是出现英文信息,后来才在同学的帮助下发现按钮没有进行注册。

下面就是具体的单击事务的处理代码(如下图)。


最后这个简单的加法计算过程发布到虚拟机上的运行结果(如图所示)


更多相关文章

  1. Android布局文件中常用的长度单位解析
  2. adb:) adb push、pull、logcat and etc
  3. Ubuntu下编译android所需ffmpeg的so库
  4. 从零开始--系统深入学习android(实践-让我们开始写代码-Android框
  5. Android(安卓)调用网易微博开放API
  6. Android驱动程序开发实例精讲-0_Android系统HAL驱动开发经典案例
  7. Android(安卓)设置ImageView中图片的显示方式
  8. Android(安卓)Rxjava+Retrofit网络请求框架封装(一)
  9. 使用Jquery Mobile设计Android通讯录

随机推荐

  1. Android intent消息通知机制
  2. android流媒体框架介绍
  3. 定制android设备启动后进入的初始界面
  4. Android Studio配置Flutter遇到的问题及
  5. 在Android中使用Application保存全局变量
  6. android中动态给EditText获得焦点并弹起
  7. Google 发布 Android Design 网站
  8. Android本地视频播放器开发--ffmpeg解码
  9. Android -- Button(按钮)的几种监听方式
  10. android 模拟器键盘控制键不能用 以及 设