//此系列博文是《第一行Android代码》的学习笔记,如有错漏,欢迎指正!
1、打开Android Studio时出现以下界面,点击”start a new Android Studio project”来新建一个项目:
2、出现以下界面,填好项目的名字和储存位置,点击next:
3、选好Minimum SDK继续点击next:
4、选择一个blank activity,点击next:
5、为刚才的activity填写相关信息,然后点击next:
至此,一个project就建立好了。下面熟悉一下AS的操作界面。
● 可以在help-> find action 搜索color & fonts ,进入下面界面,设置字体和颜色:
● 打开 AndroidManifest.xml 文件,从中可以找到如下代码:
<activity android:name="com.test.helloworld.HelloWorldActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>
这段代码表示对 HelloWorldActivity这个活动进行注册,没有在AndroidManifest.xml 里注册的活动是不能使用的。其中 intent-filter 里的两行代码非常重要,
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAqoAAAA8CAIAAAAhRw9KAAATIklEQVR4nO2dzW4azbaG9+2cVcNj+ft0JBSwjEDHg5YjGWYYBh7EYseTQ0s+DJA8yWQj2UaKM4dIMZLnGwaJnKkvxLmMPSi6enX9dRsq2KTfRwxMd/12tfutWmtV8w8BAAAAgJLxj9duAAAAAAC2DeQfAAAAKB1h5P+vv/4KUg4AAAAAtgDkHwAAACgdkH8AAACgdED+AQAAgNIB+QcAAABKB+QfAAAAKB2QfwAAAKB0QP5BKSDa68+7s0mFqDJ67N4O9167RQAEIMiNHV2eXDcoeNvAG2e35Z8aR0/fjiLCjSuEEETts/cHf15dQagN27PHdr9JrUl39hi1gt4zRJX+tuYT26wLvH02v7GJqg83VSEE0f71t1PMA8rDDss/UfXh92s/NY6evn946L71f4njzv2XeP4phCTT3x8/De4Hh84uB6xrOxBVRo/tfpOo2bgNrf2tSffrz14QcwI1G7eP3VHP2byX1pVbYKn43VdDLsS1AaoN219/9mbzRi2566gXmTpNvejrzx7/jHpkFiiX+KrAIDc2dY+U5BPtX387ucCCqhzsqvwTVR++B7tNqXvi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flkeVUXZawC9v4tdXLWQxkkN9owr33Fvv85e99ofbIUJH/nuW/tB+Kzss/8I2AzB395nH5QyAy3C69c698S919lvsBxl/kn/jn1aahrRYFO0+C/r79P5ARfurLXzajj5tZ6DcEHic7BJUB617BbXqrBv/kg1+usHfrEuddW38U9vztK886G8a1+XZf//rn9K7vxh3VrsGpnFdRgkk1gK+8W+xcdwfDyK7He6pIHZlENZ29Gnh7tIX20o2v2nR0aY5N3fjn2mFdtUl/HLiKDC3XzyvZ+/cjIXOrVegf+6ijUvueK3XeKv9fJSdAXg2/rlGedXBoX7c1WX7K3Ufo5PkRbyaclsD8tkmhVWsg+utf9rV4NrPe5r/0t8kvkG/qiw+Yw28e/2h/XZ2W/5fBct2vkDbSLjtAQDwNrFs5wv0yhr8MtPalPnF7WsD+V8H7T1CzxuHkvK3AIVqJADgN6G9R2jzX4M03/UEwO8G8g8AAACUDsg/AAAAUDog/wAAAEDpgPwDAAAApQPyDwAAAJSOMPIPAAAAgB0C8g8AAACUjv8A6ZccZCDeoG0AAAAASUVORK5CYII=" alt="" />
表示 HelloWorldActivity 是这个项目的主活动,在手机上点击应用图标,首先启动的就是这个活动。
● Layout->activity_main.xml 是布局文件,决定着界面的布局
● MainActivity是一个activity的逻辑实现:
此外res->drawable 是存储图片资源的,res->values->strings.xml是用来储存字符串资源的。例如刚刚在 strings.xml中找到的 Hello world!字符串,我们有两种方式可以引用它:
1) 在代码中通过 R.string.hello_world 可以获得该字符串的引用;
2) 在XML中通过@string/hello_world 可以获得该字符串的引用。
//End.