paip.android环境搭建与开发事例

好长时间没有玩AndROID了。。以前常常做ANDROID的,今天决定在下载一个要做个时间设置器

作者Attilax ,  EMAIL:1466519819@qq.com
来源:attilax的专栏
地址:http://blog.csdn.net/attilax

1.       下载ECLIPSE+ADT+SDK

以前都是一个个单独下载,现在都可以集成在一起了。。

adt-bundle-windows-x86-20130729.ZIP  (400M)

打开一看,晕,连C++都有了。。全面..

2.       建立项目

NEW >ANDROID APPLICATION..

MINI S DK:默认2.2,,比较合理不用改

Target sdk:指明最高SDK版本。。默认4.3,为了兼容性,也改成2.2.

Complile withd: 默认4.3,无法改改。还好,这个不影响。最后生成的APK可以在2.2下运行。。

3.       建立界面

拖拉个文本框,拖拉个按钮上去如下图

/atiapp2/res/layout/activity_main_activity1.xml  就是界面文件

<RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin"

android:paddingLeft="@dimen/activity_horizontal_margin"

android:paddingRight="@dimen/activity_horizontal_margin"

android:paddingTop="@dimen/activity_vertical_margin"

tools:context=".MainActivity1" >

<TextView

android:id="@+id/textView1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="@string/hello_world" />

<Button

android:id="@+id/button1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignLeft="@+id/textView1"

android:layout_below="@+id/textView1"

android:layout_marginLeft="30dp"

android:layout_marginTop="104dp"

android:text="Button" />

</RelativeLayout>

4.           查看启动界面

/atiapp2/AndroidManifest.xml

要死有多个界面,可以指定启动界面

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

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

package="com.example.atiapp2"

android:versionCode="1"

android:versionName="1.0" >

<uses-sdk

android:minSdkVersion="8"

android:targetSdkVersion="8" />

<application

android:allowBackup="true"

android:icon="@drawable/ic_launcher"

android:label="@string/app_name"

android:theme="@style/AppTheme" >

<activity

android:name="com.example.atiapp2.MainActivity1"

android:label="@string/app_name" >

<intent-filter>

<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />

</intent-filter>

</activity>

</application>

</manifest>

5.  建立按键点击事件

<Button

android:id="@+id/button25"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignLeft="@+id/editText1"

android:layout_below="@+id/editText1"

android:layout_marginTop="28dp"

android:text="Button"

android:onClick="button1click" />

-----------MainActivity.java-------

publicvoid button1click(View view)

{

EditText  edt=(EditText)findViewById(R.id.editText1);

String str="my name is attilax";

edt.setText(str);

}

其中,R.java是系统自动生成。。所有的多个界面控件ID都累积在那里

6.调试

调试前要建立个AVD虚拟设备..

再开始RUN AS>ANDROID APPLICATION

可以在CONSOLE下看到当前进展。。。模拟器启动比较慢,耐心等待。模拟器启动后不用关。。以后再次调试就很快。

[2013-08-05 22:18:52 - atiapp2] ------------------------------

[2013-08-05 22:18:52 - atiapp2] Android Launch!

[2013-08-05 22:18:52 - atiapp2] adb is running normally.

[2013-08-05 22:18:52 - atiapp2] Performing com.example.atiapp2.MainActivity1 activity launch

[2013-08-05 22:18:52 - atiapp2] Automatic Target Mode: launching new emulator with compatible AVD 'avd1'

[2013-08-05 22:18:52 - atiapp2] Launching a new emulator with Virtual Device 'avd1'

[2013-08-05 22:19:00 - Emulator] could not get wglGetExtensionsStringARB

[2013-08-05 22:19:00 - Emulator] could not get wglGetExtensionsStringARB

[2013-08-05 22:19:00 - Emulator] could not get wglGetExtensionsStringARB

[2013-08-05 22:19:00 - Emulator] could not get wglGetExtensionsStringARB

[2013-08-05 22:19:00 - Emulator] could not get wglGetExtensionsStringARB

[2013-08-05 22:19:00 - Emulator] could not get wglGetExtensionsStringARB

[2013-08-05 22:19:00 - Emulator] could not get wglGetExtensionsStringARB

[2013-08-05 22:19:00 - Emulator] could not get wglGetExtensionsStringARB

[2013-08-05 22:19:00 - Emulator] Failed to create Context 0x3005

[2013-08-05 22:19:00 - Emulator] emulator: WARNING: Could not initialize OpenglES emulation, using software renderer.

[2013-08-05 22:19:03 - atiapp2] New emulator found: emulator-5554

[2013-08-05 22:19:03 - atiapp2] Waiting for HOME ('android.process.acore') to be launched...

[2013-08-05 22:19:52 - atiapp2] HOME is up on device 'emulator-5554'

[2013-08-05 22:19:52 - atiapp2] Uploading atiapp2.apk onto device 'emulator-5554'

[2013-08-05 22:19:52 - atiapp2] Installing atiapp2.apk...

[2013-08-05 22:20:37 - atiapp2] Success!

[2013-08-05 22:20:37 - atiapp2] Starting activity com.example.atiapp2.MainActivity1 on device emulator-5554

[2013-08-05 22:20:39 - atiapp2] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.atiapp2/.MainActivity1 }

[2013-08-05 22:20:39 - atiapp2] ActivityManager: Warning: Activity not started, its current task has been brought to the front

就OK了。。

模拟器启动后不用关。。以后再次调试就很快。

参考:

Android开发之旅:环境搭建及HelloWorld - 吴秦 - 博客园

最新文章

  1. UVA1225
  2. Egret和Http请求 (Ajax、XMLHttpRequest、Post、Get)
  3. Python核心编程(切片索引的更多内容)
  4. [Javascript] The &quot;this&quot; keyword
  5. [Android-2A] -仿IOS微信滑动删除_SwipeListview左滑删除例子
  6. C# 调用Windows API实现两个进程间的通信
  7. 利用数据库链做DML操作时报ORA-02069: global_names parameter must be set to TRUE for this operation
  8. [Stephen]自定义SimpleAdapter
  9. MvvmCross[翻译] 使用Xamarin与MvvmCross完成一个跨平台App
  10. 从一个标准 url 里取出文件的扩展名
  11. PHP创建桌面快捷方式实例
  12. XAMPP的Apache服务器无法正常启动解决方案
  13. java中文乱码解决之道(二)—–字符编码详解:基础知识 + ASCII + GB**
  14. Python 第十一篇:开发堡垒机
  15. Python Excel 多sheet 多条数据 自定义写入
  16. [android]__如何在studio中导入,使用开源的UI组件
  17. vue中element-ui树形控件自定义节点,注意一下
  18. Mysql推荐使用规范(转)
  19. mysql03
  20. Django中的分页,cookies与session

热门文章

  1. java.lang.ClassCastException: sun.proxy.$Proxy11 cannot be cast to分析
  2. RotateDisp – 一键旋转显示画面 - 小众软件
  3. extjs表单
  4. ZOJ 1859 Matrix Searching(二维线段树)
  5. poj3461 Oulipo (KMP模板题~) 前面哪些也是模板题 O.O
  6. STM32学习之路-SysTick的应用(时间延迟)
  7. git digest
  8. Copy xml 文件
  9. iptables 小结
  10. PHP SPL他们留下的宝石