黑马程序员-关于安卓的一些知识点摘录

------- android培训java培训、期待与您交流! ----------

A:目录介绍

B:文件夹及文件描述

1:bin 文件夹

classes.dex HelloAndroid.apk 自定义的包文件夹

编译的java 二进制码Android 安装包(APK 存放编译后的字节码文件

<LinearLayout></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:layout_width="fill_parent" 横向填充满

android:layout_height="wrap_content" 纵向按实际高度填充

android:text="@string/hello" 要引用到的hello字符串

/> 图形空间派生于View

<Button

android:id="@+id/widget40_button_OK" button控件ID

android:layout_width="wrap_content"

android:layout_height="wrap_content" 按实际宽度高度显示填充

android:text="OK"

></Button>

2:

R.java

通过res 文件夹下的xml 文件定义自动生成的,main.xml ico.png string.xml 是配套的关联,进行修改后

R.java 自动重新生成

AndroidManifest.xml

有关版本,程序信息,java 包,程序图标,程序记录信息等。

3:  一个例子

添加编辑框与按钮的代码

package zyf.Study.AndroidSturdyByMyself;

import android.app.Activity;

import android.os.Bundle;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.Button;

import android.widget.EditText;

import android.widget.TextView;

public class AndroidSturdyByMyself extends Activity {

private EditText getNameEditText;

private Button button_Login;

private TextView show_Login_TextView;

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

getNameEditText=(EditText)findViewById(R.id.widget29_getName_EditText);

button_Login=(Button)findViewById(R.id.widget30_Login_Button);

show_Login_TextView=(TextView)findViewById(R.id.widget31_showLogin_TextView);

button_Login.setOnClickListener(new OnClickListener(){

@Override

public void onClick(View v) {

// TODO Auto-generated method stub

show_Login_TextView.setText(getNameEditText.getText()+"欢迎您进入");

}

});

}

}

重要包的描述:

android.app :提供高层的程序模型、提供基本的运行环境

android.content :包含各种的对设备上的数据进行访问和发布的类

android.database :通过内容提供者浏览和操作数据库

android.graphics :底层的图形库,包含画布,颜色过滤,点,矩形,可以将他们直接绘制到屏幕上.

android.location :定位和相关服务的类

android.media :提供一些类管理多种音频、视频的媒体接口

android.net :提供帮助网络访问的类,超过通常的java.net.* 接口

android.os :提供了系统服务、消息传输、IPC 机制

android.opengl :提供OpenGL 的工具

android.provider :提供类访问Android 的内容提供者

android.telephony :提供与拨打电话相关的API 交互

android.view :提供基础的用户界面接口框架

android.util :涉及工具性的方法,例如时间日期的操作

android.webkit :默认浏览器操作接口

android.widget :包含各种UI 元素(大部分是可见的)在应用程序的屏幕中使用

C:文件解释:

Class文件------Java编译后的目标文件

Dex文件-----Android平台上的可执行文件

Apk文件-------Android上的安装文件

D:

AndroidManifest.xml:工程的描述文件,在运行时有用处

Android.mk:整个工程的Makefile

2:classes.dex

是一个最重要的文件,它是给Android JAVA 虚拟机Dalvik 运行的字节码文

件。

3:classes.jar

是一个JAR 文件,JAR 的含义为Java ARchive,也就是Java 归档,是一种与平台

无关的文件格式,可将多个文件合成一个文件。解压缩之后的目录结构:(JAVA 标准编译得

到的类)

4:一个例子

package com.example.android.helloactivity;

import android.app.Activity;

import android.os.Bundle;

public class HelloActivity extends Activity {

public HelloActivity() {

}@

Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.hello_activity);

}

}

解释:

com.example.android.helloactivity 表示的是这个包的名称在文件的头部引入了两个包

android.app.Activity 是一个Android 活动( Activity)包,每一个Android 活动都需要继承

Activity 类。

android.os.Bundle 用于映射字符串的值。

onCreate()是一个重载的函数,在这个函数中实现应用程序创建的所执行的过程。其中

setContentView()设置当前的视图(View)。

设置的方法是使用一个文件,这个文件因此决定了视图中包含的内容。这里使用的是

R.layout.hello_activity,表示从res/layout/目录中使用hello_activity.xml 文件。

res/layout/hello_activity.xml 文件的内容如下所示:

<?xml version="1.0" encoding="utf-8"?>

<EditText xmlns:android="http://schemas.android.com/apk/res/android"

android:id="@+id/text"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:textSize="18sp"

android:autoText="true"

android:capitalize="sentences"

android:text="@string/hello_activity_text_text" />

解释:其中定义了一个可编辑的文本( EditText),下面的各项其实是它的各种属性, android:text 表示这个文本的

内容,string/hello_activity_text_text 表示找到相应的文件也就是res/value/string.xml 文件中的

hello_activity_text_text 文本。

res/value/string.xml 的内容如下所示:

<?xml version="1.0" encoding="utf-8"?>

<resources>

<string name="hello_activity_text_text" >He llo, World!</string>

</resources>

hello_activity_text_text 文本被res/layout/hello_activity.xml 文件引用,正是应用程序运行时在

屏幕显示的文本。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值