Android-study-01

1、HelloWorld

1.1 Android系统架构

  • Linux内核层:Android系统是基于Linux内核的,为设备提供各种硬件的底层驱动

  • 系统运行库层:通过一些C/C++来为系统提供主要的特性支持。SQLite提供数据库 还有Android运行时库,主要提供一些核心库能够使用java语言来编写应用,还包含了Dalvik虚拟机,使每一个Android应用都能运行在独立的进程当中。

  • 应用框架层:提供了构建应用程序时可能用到的各种API。

  • 应用层:安装在手机上的应用程序系统架构

1.2 四大组件

  • Activity :所有应用程序的门面,我们所看到的东西

  • Service:在后台默默运行的

  • Broadcast Receiver:允许你的应用接收来自各处的广播消息,电话信息

  • Content Provider:应用程序之间共享数据

1.3 文件结构

  • java 放置java代码的地方

  • res 资源 :

  • drawable 放图片

  • layout 放布局

  • values 放字符串、样式、颜色等配置

  • mipmap用来放应用图标的

1.4 项目中的资源

AndroidManifest.xml : Android项目的配置文件,四大组件都需要在这里注册

 <activity android:name=".MainActivity">
  <intent-filter>
  <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
  </intent-filter>
 </activity>

对这个activity进行了注册,并且设置了这个项目为主活动。

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

Activity是Android系统提供的一个活动基类,我们所有的活动都需要继承他

onCreate( )方法是一个活动被创建时必定要执行的方法

setContentView( )为当前的活动引入一个布局

 <resources>
     <string name="app_name">应用程序名字</string>
 </resources>
 <application
         android:allowBackup="true"
         android:icon="@mipmap/ic_launcher"
         android:label="@string/app_name"
         android:roundIcon="@mipmap/ic_launcher_round"
         android:supportsRtl="true"
         android:theme="@style/AppTheme">
 </application>

引用方式

  • 代码中:R.string.hello_world

  • XML中:@string/hello_world

1.5 日志工具

Log.v( )、Log.d( )、Log.i( )、Log.w( )、Log.e( )

两个参数,tag 一般传入当前的类名,msg 具体打印的内容

猜你喜欢

转载自www.cnblogs.com/dysncs/p/12423529.html