您的位置:首页 > 移动开发 > Android开发

Android 学习笔记1

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

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

android:text="Button1"

提示是要@string.

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

警告消失。

       线性布局比较简单,如果放置几行或几列的话,要使用线性布局嵌套了,然而复制了代码后,提示错误“Unexpected
namespace 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>


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android