Android 学习笔记1

来源:互联网 发布:掷茭杯的算法 编辑:程序博客网 时间:2024/06/16 03:40

          Eclipse+ADT+sdk 平台搭建好后,新建工程,使用安卓虚拟设备管理新建了模拟器,运行工程,结果模拟器死机了,经过查找,发现工程使用的设备和模拟器里的设备不一致,改过来后,出现了HELLOW WORLD!这才算是真正搭建好了。

        在学习线性布局时 ,又遇到了警告 

android:text="Button1"

提示是要@string.

<string name="Button1">按钮1</string> 
在string.xml添加上面资源,在布局中修改为
android:text="@string/Button1"

警告消失。

       线性布局比较简单,如果放置几行或几列的话,要使用线性布局嵌套了,然而复制了代码后,提示错误“Unexpectednamespace prefix "xmlns"found for tag LinearLayout”,

网上查到删除嵌套里的

xmlns:android=<a target=_blank href="http://schemas.android.com/apk/res/android">http://schemas.android.com/apk/res/android</a>

就OK了。

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:orientation="vertical"     android:layout_width="match_parent"    android:layout_height="match_parent"        >    <Button android:id="@+id/Button1"                       android:layout_width="fill_parent"             android:layout_height="wrap_content"                         android:text="@string/Button1"                                   />         <LinearLayout     android:orientation="horizontal"     android:layout_width="fill_parent"    android:layout_height="fill_parent"        >        <Button android:id="@+id/Button2"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:text="@string/Button2"     android:layout_weight="1"    />     <Button android:id="@+id/Button3"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:text="@string/Button3"     android:layout_weight="1"     />     <Button android:id="@+id/Button4"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:text="@string/Button4"     android:layout_weight="1"     />     </LinearLayout></LinearLayout>



1 0
原创粉丝点击