zoukankan      html  css  js  c++  java
  • android学习三---创建第一个程序

    1.创建一个Helloworld程序

    1.1 new-android application

    点击file-new-android application出现如下界面

    image 

    填上应用名,项目名,包名,选择所需最低的SDK版本,目标版本和编译版本,next next

    image

    选择一个Activity,默认是blank。然后Finish。

    就创建好一个android项目了。不需要添加任何代码,就可以运行了。

    2.创建虚拟机和在真机上运行

    2.1 模拟器运行

    打开工具栏上AVD的按钮

    image

    出现创建VD(虚拟机)的界面

    image

    点击creat就可以创建了。

    image

    主要有Android 虚拟设备的名称( Name)、目标的 Target( SDK)、 SD Card 的路径,以及虚拟设备的 Skin等

    红色标注的两项:一个是选择CPU有ARM和X86(Atom)。二是模拟方式

    Snaphost和Use Host GPU这两者的区别

    The Snapshot option speeds up the boot of the emulator by saving a snapshot of its RAM once it has booted, and restoring from that snapshot on future uses. That way, it doesn't have to run the boot process (which is slow, because it's emulated) every time you start the emulator.

    The Use Host GPU option uses the host computer's OpenGL implementation (which is probably hardware-accelerated, on your real GPU) to evaluate OpenGL commands inside the emulated system. Put another way, when a program inside the emulator uses OpenGL for graphics operations, the work goes out to your real GPU, and the result goes back into the emulator, instead of emulating a GPU (which is very slow). The result is a significant speed-up, especially when you consider that most view and canvas drawing uses OpenGL in Android ≥ 4, even in non-graphics apps.

    You can't have both options turned on at once.

    Snapshot通过boot时保存RAM的快照来加速模拟器的启动。所以每次启动模拟器时不需要运行boot过程。

    Use Host GPU :使用宿主计算机的OpenGL实现,当emulator需要使用OpenGL时,会使用计算机的GPU,而不用模拟,所以可以加速一些图形处理。

    如果计算机性能一般般,最好还是选Snapshot。

    image

    出现如上的节目表示创建成功。在这之前请耐心等待,启动过程很久。

    简单的运用程序效果图

    image

    2.2 真机运行

    需要一台android手机,能够连接电脑,并下好驱动。这时点Run as android application。就会有机器出现在下面的选项中,

    image

    如果有android手机最好选择真机进行调试,虚拟机启动太慢了,安装,运行时间也很久。

    3.android项目目录结构

    image

    主要介绍几个

    3.1 src :

    是项目的所有包及源文件( .java)主要实现应用的功能等

    3.2 res:

    文件夹中则包含了项目中
    的所有资源,比如,程序图标( drawable)、布局文件( layout)、常量( values)等

    3.3 gen:

    代表的是自动创建的文件,其中R.java 是在建立项目时自动生成的,这个文件是只读模式,不能更改, R.java 文件是定义该项目所有
    资源的索引文件。

    3.4 AndroidManfest.xml:

    AndroidManfest.xml 文件则包含了该项目中所使用的 Activity、 Service、 Receiver。

  • 相关阅读:
    I can do more…
    在希望的田野上
    卓越管理培训笔记
    Python 学习小计
    谈谈“直抒己见”
    [更新]关于博客园不支持RSS全文输出的解决方案
    效率生活二三事
    个人阅读解决方案
    Oracle函数sys_connect_by_path 详解
    基础班-模板配置
  • 原文地址:https://www.cnblogs.com/dawnminghuang/p/4122791.html
Copyright © 2011-2022 走看看