zoukankan      html  css  js  c++  java
  • Android学习——活动创建

    在AndroidManifest文件中注册

    Androidmanifest文件相当于一个统领,记录着这个app中最重要的信息。

    复制代码
     1 <?xml version="1.0" encoding="utf-8"?>
     2 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     3     xmlns:tools="http://schemas.android.com/tools"
     4     package="com.example.myapplication">
     5 
     6     <application
     7         android:allowBackup="true"
     8         android:icon="@mipmap/ic_launcher"
     9         android:label="@string/app_name"
    10         android:roundIcon="@mipmap/ic_launcher_round"
    11         android:supportsRtl="true"
    12         android:theme="@style/AppTheme"
    13         tools:ignore="GoogleAppIndexingWarning">
    14         <activity android:name=".FirstActivity">
    15             <intent-filter>
    16                 <action android:name="android.intent.action.MAIN" />
    17                 <category android:name="android.intent.category.LAUNCHER" />
    18             </intent-filter>
    19         </activity>
    20         <activity android:name=".SecondActivity">
    21 
    22         </activity>
    23         <activity android:name=".Main3Activity"></activity>
    24     </application>
    25 
    26 </manifest>
    复制代码

    每一个activity,都要在这个文件中注册,也就是那些activity标签。

    android:name属性值是.FirstActivity,因为在manifest标签中已经指定了package的名字,所以可以在下面写活动名称的时候使用简略写法:.FirstActivity。

    活动注册好以后需要配置一个标签用来声明主活动:<intent-filter>,并加入声明:

    1 <action android:name="android.intent.action.MAIN" />
    2 <category android:name="android.intent.category.LAUNCHER" />

    加入这三步,就可以让一个普通的活动变成主活动。

    这样,我们一个最基本的活动就创建完成了。

  • 相关阅读:
    weblogic详解
    Java实现视频网站的视频上传、视频转码、及视频播放功能(ffmpeg)
    Java上传视频(mencoder)
    input标签type="file"上传文件的css样式
    jQuery系列:选择器
    jQuery系列:Ajax
    Sql Server系列:规范化及基本设计
    Sql Server系列:查询分页语句
    Sql Server系列:通用表表达式CTE
    Sql Server系列:子查询
  • 原文地址:https://www.cnblogs.com/znjy/p/14907583.html
Copyright © 2011-2022 走看看