安卓Activity学习笔记

【eclipse中的自动补全】
http://jingyan.baidu.com/article/0964eca23deecd8284f5366d.html
http://jingyan.baidu.com/album/b24f6c822858b986bfe5dae2.html?picindex=2
【几个重要的文件】 
AndroidManifest.xml 清单文件【加activity、加权限】
src中的.java
res 中的layout 布局文件
res 中的values 下的 strings.xml 文字部分 定义(便于修改 国际化)所有文字都能在国际化里边改
当然直接写也可以,但是有感叹号警报而且不便于修改


【快捷键】
【Ctrl+1】 快速修复(最经典的快捷键,就不用多说了)
【Ctrl+点击】 快速跳转



显示文本的控件  TextView
输入框控件   EditText
按钮控件 Button


【安卓五大布局】
【相对布局】
<RelativeLayout />
</RelativeLayout>
相对布局中所有写的代码都有参照物
<RelativeLayout 
android:layout_width="match_parent"    【match_parent】  填充父容器。就是手机屏幕多宽多高布局就多大。
android:layout_height="match_parent"
/>
【线性布局】
<LinearLayout /> 线性布局 控件从上到下 一条线排开。
android:orientation="horizontal"  方向是水平的
android:orientation="vertical"    方向是垂直的 
android:layout_height="fill_content"   【fill_content】 填充父容器。与【match_parent】相同
android:layout_width="match_parent"


【显示框】
<TextView
        android:id="@+id/title"
        android:layout_width="wrap_content"    【wrap_content】 包裹内容 
        android:layout_height="wrap_content"
        android:text="@string/title" />【ctrl+1+点击可自动添加入string】
【输入框】
<EditText
        android:id="@+id/number1"   【@+id/】加ID
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
android:hint="@string/et_account_hint"【特有方法】初始显示,输入后消失
        android:layout_below="@id/title"【@id/】 引用id【android:layout_below】相对布局必须有相对位置设置
        />
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/number1"
        android:text="@string/callnumber" 
android:onClick="call" 【按钮中的专用方法】需要在.java中设置一个call方法
【.xml中的注释方法】<!-- 注释 -->
【四种点击事件:四种方法】


第四种方法是最常用的


【圆形带边框按钮】http://www.cnblogs.com/lvlv/p/3909237.html
在drawable中新建.xml文件即可


.xml
<?xml version="1.0" encoding="utf-8"?>
<shape 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle"> 
    <!-- 填充的颜色 --> 
    <solid android:color="#7C8593" /> 
    <!-- 设置按钮的四个角为弧形 --> 
    <!-- android:radius 弧形的半径 --> 
    <corners android:radius="10dp" /> 
      
<!-- padding:Button里面的文字与Button边界的间隔 --> 
<padding 
   android:left="10dp" 
   android:top="10dp" 
   android:right="10dp" 
   android:bottom="10dp" 
/> 
</shape>        






<ImageView
        android:id="@+id/imageView1"
        android:layout_width="200dp"
        android:layout_height="400dp"
        android:layout_above="@+id/button2"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="27dp"
        android:src="@drawable/welcome" />
【.xml文件解析】
可标记 可扩展 语言




【得到控件】
FingViewById(R.id.id名字)
返回值类型为View,View是android中所有控件的父类
所以进行一个强制类型转换 
【强制类型转化】
(TextView)FingViewById(R.id.id名字)  即强制转换为 TextView类型的
然后再赋值即可。
TextView id名字=(TextView)FingViewById(R.id.id名字);






































  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值