android初窥

android似乎已经形成了一种浪潮,做不了第一个吃螃蟹的人,只能追着去赶浪,谨在此记录下学习android的随笔,乱写乱画,切莫介意。

 

android是神马,以及android的安装、配置等网上大把,我就不写在这了,我用的ide是intellj,iteye上也有教程,大家可以查查。

 

  今天就说说第一个demo,Hello,world!

 

先看代码:

package com.example;

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

public class MyActivity extends Activity
{
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}
 

这个代码是由intellj自动生成的Helloworld的代码,先看看疑惑的地方:

Activity:活动,android的模块,api描述:An activity is a single, focused thing that the user can do. Almost all activities interact with the user, so the Activity class takes care of creating a window for you in which you can place your UI with setContentView(View).简单理解,即Activity代表一个用户所能看到的屏幕,通过setContentView(View)来体现你想在屏幕上展示的UI;onCreate(Bundle) is where you initialize your activity.初始化activity,所有应用的activity都继承于android.app.Activity。

Bundle:A mapping from String values to various Parcelable types.英语不好,类似于key为String类型的map。

R:建立项目时自动生成,是该项目所有资源的索引文件,常量名和res文件夹中的文件名项目,该文件不能编辑,更新资源时,刷新该项目即可。

R.layout.main:即res/layout/main.xml,布局xml

main.xml

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

  xml中的LinearLayout :线性布局,以后会经常用到,后面说。

 

@string/hello:即res/value/string.xml

<?xml version="1.0" encoding="utf-8"?>

<resources>
    <string name="app_name">MyActivity</string>
    <string name="hello">Hello,world!</string>
</resources>
 

string.xml:资源文件,不多说,以后经常会用,包括布局,颜色,样式等;说说是如何获取这些资源的,

Context实例化Resources,再获取String

Resources r=this.getContext().getResources():
String appname=((String)r.getString(R.string.app_name));
String hello=((String)r.getString(R.string.hello));

 

这时还没有结束,任何应用程序,都必须在AndroidManifest.xml声明所有使用到得模块:

AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:label="and" android:icon="@drawable/icon">
        <activity android:name="MyActivity"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

  这里主要需要关注的地方:

package:声明应用程序包;

application:包含package中application级别组件的根节点。此元素也可包含application的一些全局和默认属性,如标签、icon、主题、必要的权限等,一个manifest只能包含一个或零个此元素;

android:label:名字

android:icon:图标

activity:声明activity,每个activity必须有一个对应的标记,否则无法运行,另外,为了支持运行时查找Activity,可包含一个或多个intent-filter来描述Activity所支持的操作;

android:name:默认启动的actiivity;

intent-filter:声明指定的一组组件支持的Intent值,从而形成IntentFilter,除了能在此元素下指定不同类型的值,属性也能放到这里来描述一个操作所需的唯一标签、icon和其他信息。

action:组件支持的Intent action

category:组件支持的Intent Category。这里指定了应用程序默认启动的Activity。

uses-sdk:sdk版本

 

 

以上部分内容来自于:android api,android应用开发揭秘,android基础教程。

内容概要:本文深入探讨了DevOps流程落地中自动化测试与监控体系的构建,强调二者是保障软件质量和系统稳定性的重要支柱。自动化测试涵盖从单元测试到端到端测试的全流程自动化,而监控体系则通过实时采集和分析系统数据,及时发现并解决问题。文章介绍了测试金字塔模型的应用、监控指标的分层设计、测试与生产环境的一致性构建以及告警策略的精细化设置等核心技巧。此外,还提供了基于Python和Prometheus的具体代码案例,包括自动化接口测试脚本和监控指标暴露的实现,展示了如何在实际项目中应用这些技术和方法。 适合人群:对DevOps有一定了解,从事软件开发、运维或测试工作的技术人员,特别是那些希望提升自动化测试和监控能力的从业者。 使用场景及目标:①高并发业务系统中,模拟大规模用户请求,验证系统抗压能力和稳定性;②关键业务流程保障,确保金融交易、医疗数据处理等敏感业务的合规性和可追溯性;③微服务架构系统下,通过契约测试和分布式链路追踪,保证服务间的兼容性和故障快速定位。 阅读建议:本文不仅提供了理论指导,还有详细的代码示例,建议读者结合自身项目的实际情况,逐步实践文中提到的技术和方法,特别是在构建自动化测试框架和监控系统时,关注环境一致性、测试覆盖率和性能指标等方面。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值