Android开发——目录结构和执行过程认识以及日志工具的使用(二)

活动注册

分析helloworld代码
HelloWorldActivity活动进行注册

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

引用图标 字符等的操作

在这里插入图片描述
在这里插入图片描述

      <resources>
   <string name="app_name">Demo1</string>
</resources>

代码中 通过R.string.hello_world可以获得该字符串的引用
在xml中 通过@string/hello_world可以获得该字符串的引用
引用图片/图标/布局文件可以分别把string换成drawable/mipmap/layout

例如:
在这里插入图片描述

android:icon="@string/ic_launcher"


详解build.grade

buildscript {
        repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
    }
}
allprojects {
    repositories {
        google()
        jcenter()
    }
}	

1.jcenter是一个代码托管仓库,声明了这一行代码就可以在项目中轻松的引用任何rcenter上的开源项目了
2.dependencies闭包中使用classpath声明一个Gradle插件
因为Grade不是只面向android的

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.demo1"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

1.com.android.application&&com.android.library 应用程序模块&&库模块
前者可以直接运行 后者必须依附别的应用程序模块来运行
2. defaultConfig闭包中:
minSdkVersion 15 targetSdkVersion 28
最低兼容到android 4.0

3.buildTypes闭包 用于指定生成安装文件的相关配置
4.dependencies 闭包
fileTree(dir: ‘libs’, include: [’*.jar’]) 本地依赖声明 libs目录中所有.jar后缀文件都添加到项目的构建路径之中
‘com.android.support:appcompat-v7:28.0.0’ 远程依赖声明
testImplementation 声明测试用例库 暂时用不到


使用android日志工具Log

类似:
在这里插入图片描述
在这里插入图片描述

快捷键 logd logi
一般最简单的是在onCretate外打logt
在这里插入图片描述
在logcat中找到关键信息:
在这里插入图片描述
logcat中只有三个过滤器
在这里插入图片描述
只显示当前选中的程序日志/谷歌提供的一个分析工具/显示所有/自定义
在这里插入图片描述
logcat中的日志级别控制
逐个级递增。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值