android开发实例第一季第一集--第一个Activity

此作品会拿一个APK的全部开发过程展示出来,android的基础知识不会讲解,需要网友具备一些java和android的基础知识.欢迎大家一起讨论,不足之处请大家多多包含.

  先展示一下这个APK的成品图
  

1.第一步,创建第一个启动的Activity


package bbs.androidchina.net;

import android.os.Bundle;
import android.app.Activity;

public class AndroidChinaActivity extends Activity {

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }

}

2.初步布局 

构思:用LinearLayout布局,上面的LinearLayout占屏幕70%-80%,最下面放一个广告,占10%左右

在layout布局文件夹中修改main.xml


<?xml version="1.0" encoding="utf-8"?>
<!-- 转载请注明出处  bbs.androidchina.net   androidchina.net版权所有-->
<!-- 整个大屏幕的LinearLayout,然后在里面切出几个LinearLayout -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" 
    android:id="@+id/main"
    >
    
    <!-- 显示问题的TextView控件 -->
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" 
    android:id="@+id/main"
    android:layout_weight="8">
    
            <TextView 
            android:id="@+id/readfiletextview"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:background="@color/black"
                   />
    </LinearLayout>
    
  
    <!-- 第一栏显示的信息 -->
    <LinearLayout  
                android:id="@+id/buttonchangeLayout"
            android:layout_width="fill_parent"
            android:layout_height="30dip"
    >

                <TextView
                        android:id="@+id/buttonchange"
                        android:layout_width="fill_parent"
                        android:layout_height="match_parent"
                        android:background="@drawable/titlebg"
                />
        </LinearLayout>
        
    <!-- 第二栏显示的信息 -->
        <LinearLayout  
            android:id="@+id/xjqbuttonchangeLayout"
        android:layout_width="fill_parent"
        android:layout_height="30dip">
                
                <Button
                        android:id="@+id/adbutton"
                        android:layout_width="500dip"
                        android:layout_height="30dip"
                        android:textColor="@color/blue"
                        android:background="@drawable/titlebg"
                        android:textSize="20dip"
                />
        </LinearLayout>
    
    
        <!-- 第三栏显示的信息 -->
    <LinearLayout  
            android:id="@+id/changeLayout"
            android:layout_width="fill_parent"
            android:layout_height="50dip">

                <TextView
                        android:id="@+id/changetext"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:background="@drawable/titlebg"
                />
        </LinearLayout>

</LinearLayout>


在main.xml文件中用到了color资源文件,为了以后编辑统一和修改方便,创建一个color.xml资源文件

创建方法是在values文件夹创建一个color.xml
内容如下:


<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="black">#000000</color>
<color name="blue">#0000ff</color>
</resources>

第一集步骤做完,效果图地址 

http://bbs.androidchina.net/thread-36-1-1.html

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值