Hello World界面

MainActivity.java

package com.example.myapplication;import androidx.appcompat.app.AppCompatActivity;import android.os.Bundle;public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);//创建activity        setContentView(R.layout.activity_main); //setContentView引入layout布局    }}

activity_main.xml

<?xml version="1.0" encoding="utf-8"?><androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:app="http://schemas.android.com/apk/res-auto"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    tools:context=".MainActivity">    <TextView        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="Hello wwWorld!"        app:layout_constraintBottom_toBottomOf="parent"        app:layout_constraintLeft_toLeftOf="parent"        app:layout_constraintRight_toRightOf="parent"        app:layout_constraintTop_toTopOf="parent" /></androidx.constraintlayout.widget.ConstraintLayout>

资源RES


drawable放图片
layout放布局文件
mipmap放图标
values字符串、样式、颜色配置

构建工具 gradle

项目构建工具
分两个build.gradle文件:

外层:一般不去动这个文件

// Top-level build file where you can add configuration options common to all sub-projects/modules.//顶层构建文件,您可以在其中添加所有子项目/模块共有的配置选项。buildscript {    repositories {         google()        jcenter() //jcenter是个代码托管仓库,可以在项目中引用jcenter上的开源项目            }    dependencies { //声明了一个插件,3.4.1是插件版本号        classpath 'com.android.tools.build:gradle:3.4.1'                // NOTE: Do not place your application dependencies here; they belong        // in the individual module build.gradle files        ///注意:请勿在此处放置应用程序依赖项; 它们属于单独的模块build.gradle文件    }}allprojects {    repositories {        google()        jcenter()            }}task clean(type: Delete) {    delete rootProject.buildDir}

app内层:

//com.android.application表示这是一个应用程序模块,可直接运行;如果是com.android.library表示一个库模块,作为代码库依附于应用程序模块运行apply plugin: 'com.android.application'android {    compileSdkVersion 29 //编译版本    buildToolsVersion "29.0.2"    defaultConfig { //细节配置        applicationId "com.example.myapplication"         minSdkVersion 24        targetSdkVersion 29        versionCode 1 //项目版本号,用于生成安装文件        versionName "1.0" //项目版本名,用于生成安装文件        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"    }    buildTypes { //指定生成安装文件的相关配置        release { //生成正式版安装文件的配置            minifyEnabled false //用于指定是否对项目的代码进行混淆            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' //混淆时使用的规则文件        }    }}dependencies { //指定当前项目所有的依赖关系(本地,库,远程jcenter)    implementation fileTree(dir: 'libs', include: ['*.jar']) //本地依赖声明:将libs目录下所有.jar后缀的文件都添加到项目的构建路径中    implementation 'androidx.appcompat:appcompat:1.1.0'    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'    testImplementation 'junit:junit:4.12'     androidTestImplementation 'androidx.test:runner:1.2.0'    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'}

日志Log


v打印琐碎小信息verbose;d打印调试信息debug;i打印重要分析数据info;w打印警告信息warn;e打印错误信息error
快捷键:输入logd+tap键自动补全

例如在MainActivity.java中加入一句 Log.d

protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);        Log.d("MainActivity","??????onCreat execute");        //前者tag:对打印信息过滤,后者msg:打印的具体内容    }

tag的值可在onCreate()外面提前统一定义,①输入logt+tap键自动生成,②logd+tap键

在logcat中可见

自制日志过滤器



更多相关文章

  1. android service
  2. android操作sdcard
  3. Android带进度条文件上传
  4. android 文字滚动动画
  5. Android(安卓)studio maven pom.xml
  6. android studio 错误总结
  7. Android之SurfaceView、Camera
  8. android SQLite数据库使用实例
  9. Android(安卓)- LayoutInflater 的使用

随机推荐

  1. 认识Android
  2. android Content Provider详解
  3. Android(安卓)Uevent 分析,从kernel到fram
  4. Android入门进阶教程(12)-SystemService
  5. 【译】Kotlin Android扩展(Kotlin Android
  6. 《Android(安卓)复杂的列表视图新写法 Mu
  7. LinearLayout 线性布局管理器
  8. 探究Android异步消息的处理之Handler详解
  9. Android(安卓)Manifest文件
  10. Android单元测试