java中有"包"的概念,同样的类名在不同的包下可以使用二不会冲突。
1.目录结构
src
source code该文件夹是放项目的源代码的。
gen文件夹
下面有个R.java文件,R.java是在建立项目时自动生成的,这个文件是只读模式的,不能更改。
R.java文件中定义了一个类——R,R类中包含很多静态类,且静态类的名字都与res中的一个名字对应,即R
类定义该项目所有资源的索引。
res文件夹
资源目录,包含你项目中的资源文件并将编译进应用程序。向此目录添加资源时,会被R.java自动记录。
有drawabel、layout、values等子目录。
AndroidManifest.xml
项目的总配置文件,记录应用中所使用的各种组件。这个文件列出了应用程序所提供的功能,在这个文件中,
你可以指定应用程序使用到的服务(如电话服务、互联网服务、短信服务、GPS服务等等)。另外当你新添加一
个Activity的时候,也需要在这个文件中进行相应配置,只有配置好后,才能调用此Activity。
2.AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=" http://schemas.android.com/apk/res/android "
package="hello.wxh.packet"//使用的包名
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />支持的android最低版本号
<application
android:icon="@drawable/ic_launcher"图标
android:label="@string/app_name" >应用程序名称
<activity
android:name=".HelloActivity"activity名称
android:label="@string/app_name" >//应用程序名称
<intent-filter>
<action android:name="android.intent.action.MAIN" />动作过滤
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
3.布局文件main.xml
<?xml version="1.0" encoding="utf-8"?>
相对布局管理器
<LinearLayout xmlns:android=" http://schemas.android.com/apk/res/android "
android:layout_width="fill_parent"宽为填满屏幕(父类)
android:layout_height="fill_parent"
android:orientation="vertical" >垂直布局
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />文本标签里的字符
</LinearLayout>
4.字符资源文件
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, HelloActivity!</string>
<string name="app_name">Hello</string>
</resources>
5.java程序
在该包下建立类
package hello.wxh.packet;
import android.app.Activity;
import android.os.Bundle;
public class HelloActivity extends Activity {
/** Called when the activity is first created. */
@Override
//重载onCreate()
public void onCreate(Bundle savedInstanceState) {
//父类的onCreate()函数
super.onCreate(savedInstanceState);
//加载main布局文件
setContentView(R.layout.main);
}
}
1.目录结构
src
source code该文件夹是放项目的源代码的。
gen文件夹
下面有个R.java文件,R.java是在建立项目时自动生成的,这个文件是只读模式的,不能更改。
R.java文件中定义了一个类——R,R类中包含很多静态类,且静态类的名字都与res中的一个名字对应,即R
类定义该项目所有资源的索引。
res文件夹
资源目录,包含你项目中的资源文件并将编译进应用程序。向此目录添加资源时,会被R.java自动记录。
有drawabel、layout、values等子目录。
AndroidManifest.xml
项目的总配置文件,记录应用中所使用的各种组件。这个文件列出了应用程序所提供的功能,在这个文件中,
你可以指定应用程序使用到的服务(如电话服务、互联网服务、短信服务、GPS服务等等)。另外当你新添加一
个Activity的时候,也需要在这个文件中进行相应配置,只有配置好后,才能调用此Activity。
2.AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=" http://schemas.android.com/apk/res/android "
package="hello.wxh.packet"//使用的包名
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />支持的android最低版本号
<application
android:icon="@drawable/ic_launcher"图标
android:label="@string/app_name" >应用程序名称
<activity
android:name=".HelloActivity"activity名称
android:label="@string/app_name" >//应用程序名称
<intent-filter>
<action android:name="android.intent.action.MAIN" />动作过滤
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
3.布局文件main.xml
<?xml version="1.0" encoding="utf-8"?>
相对布局管理器
<LinearLayout xmlns:android=" http://schemas.android.com/apk/res/android "
android:layout_width="fill_parent"宽为填满屏幕(父类)
android:layout_height="fill_parent"
android:orientation="vertical" >垂直布局
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />文本标签里的字符
</LinearLayout>
4.字符资源文件
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, HelloActivity!</string>
<string name="app_name">Hello</string>
</resources>
5.java程序
在该包下建立类
package hello.wxh.packet;
import android.app.Activity;
import android.os.Bundle;
public class HelloActivity extends Activity {
/** Called when the activity is first created. */
@Override
//重载onCreate()
public void onCreate(Bundle savedInstanceState) {
//父类的onCreate()函数
super.onCreate(savedInstanceState);
//加载main布局文件
setContentView(R.layout.main);
}
}