您的位置:首页 > 移动开发 > Android开发

android(base)--Activity基本配置

2016-05-07 21:46 441 查看
1:Activity

概念:

Activity是一个可视化的用户界面。负责创建一个屏幕窗口,放置UI组件,供用户交换。

用法:

创建Activity类

在Androidmanifest.xml文件中注册

设置布局文件(可选)

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

public class myActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}


布局资源文件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Ilove google"/>

</LinearLayout>


3:AndroidManifest.xml文件

概念:它是android应用程序的清单文件,每个应用程序都必须包含,位于应用程序的根目录下。

作用:

描述了程序的基本属性。

描述了应用需要使用的权限信息。

描述包含的应用组件(activity,service,broadcast,contentprovide等等)(设置支持的屏幕类型,自定义权限,权限组)。

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.asong.test">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".myActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>

</manifest>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: