android 学习教程(三)之---工程目录结构介绍

上例子 ,推荐上篇提到的mars 老师视频先看看,学习android之前建议先学习号java基础

看似简单事情,做到好不易!工作搞android一年多了,发现不断总结是个非常好的习惯。最近比较闲大笑,总结下之前的一些基础android 知识

 

展开Eclipse 中的 "Project Explorer"窗口里的"Activity_fist "项名称,可以看见如下目录结构:

           Activity-first

                    -- - Src  (  源代码)

                            ---   example.activity

                   --- bin (放的是编译后的class文件和apk文件)

                    --- gen (自动创建R.java ,保存所有资源的ID)

                    ---- libs  (存放基础库jar文件,允许为空)

                   --- assets (放图片,视频等资源)

                   ----  res

                             ---drawable (放图片资源)

                             ---layout  (布局文件)

                             ---values(放字符串,颜色,风格等)

                   ----  .classpath (系统文件,路径参数)

                   ---- AndroidManifest.xml  (软件的权限,窗口Activity ,intent 控制器的定义)

                   ---- default.properties  (android库版本,如android-4 使用 api 4)

                   ----launcher.png  (软件的显示图标)

   

第一个程序:

   Activity 主程序:

     public class Activity_fist extends Activity {
       /** Called when the activity is first created. */


       @Override

    private  TextView myTextview=null;  (定义textview )

    private Button myButton=null;   (定义一个按钮)

     public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState); (复写onCreate方法)
        setContentView(R.layout.main); (设置窗口显示)
        TextView myTextview=(TextView) findViewById(R.id.myTextView);  (获取布局文件的id)
        Button  myButton=(Button) findViewById(R.id.myButton);
        myTextview.setText("我的第一TextView"); (设置控件上文字)
     
     }
}

 设置控件文字一. 用控件.setText 来设置,二:在mian.xml 布局文件中  android:text="这儿设置"   ,

三。在布局文件中mian.xml

     <TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/textView_text"
    />
  然后在String.xml 字符串中设置:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="hello">Hello World, HelloAndroid!</string>
    <string name="app_name">HelloAndroid</string>
    <string name="textView_text">我的第一个TextView</string>
</resources>

 

布局文件:

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TextView
    android:id="@+id/myTextView"
    android:layout_width="fill_parent" (表示填满父控件空白
    android:layout_height="wrap_content" (表示刚好足够显示当前控件内容
   
/>
<Button
    android:id="@+id/myButton"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="我的第一个button"
/>
</LinearLayout>

                      

 

               希望我的总结对大家有所帮助,大家一起学习进步,

                                              转载请给出出处,看过帮忙留言讨论

 

 


 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值