Mrljdx’s Blog

A goal without a plan is just a wish


  • 首页

  • 归档

  • 标签

  • 搜索

Receiving intents

发表于 Apr 6 2015 | 分类于 Android | | 阅读次数

原文地址:
https://github.com/excilys/androidannotations/wiki/Receiving-intents

接收意图

@Receiver注释通知你的代码的意图,而不必手工申报和注册一个BroadcastReceiver。例如:

1
2
3
4
5
6
7
8
9
@EActivity
public class MyActivity extends Activity {

@Receiver(actions = "org.androidannotations.ACTION_1")
protected void onAction1() {
// Will be called when an org.androidannotations.ACTION_1 intent is sent.
}

}

阅读全文 »

@EReceiver加强广播接收器

发表于 Apr 6 2015 | 分类于 Android | | 阅读次数

原文地址:
https://github.com/excilys/androidannotations/wiki/Enhance-broadcastreceivers

你可以使用@EReceiver注释增强一个Android BroadcastReceiver :

1
2
3
4
@EReceiver
public class MyReceiver extends BroadcastReceiver {

}

阅读全文 »

@EProvider加强contentprovider

发表于 Apr 6 2015 | 分类于 Android | | 阅读次数

原文地址:
https://github.com/excilys/androidannotations/wiki/Enhance-contentproviders

你可以使用@EProvider注释加强一个Android内容提供商与:

1
2
3
4
@EProvider
public class MyContentProvider extends ContentProvider {

}

阅读全文 »

Extra

发表于 Apr 6 2015 | 分类于 Android | | 阅读次数

原文地址:
https://github.com/excilys/androidannotations/wiki/Extras#executing-code-after-extras-injection

@Extra

@Extra注释一个从Activity中启动意图中获取正确值的字段,例如:

1
2
3
4
5
6
7
8
9
10
@EActivity
public class MyActivity extends Activity {

@Extra("myStringExtra")
String myMessage;

@Extra("myDateExtra")
Date myDateExtraWithDefaultValue = new Date();

}

阅读全文 »

@EFragment增强碎片

发表于 Apr 6 2015 | 分类于 Android | | 阅读次数

原文地址:
https://github.com/excilys/androidannotations/wiki/Enhance-Fragments

支持FragmentActivity

在AndroidAnnotations 2.6之前,没有支持片段注入。然而,我们确保至少继承FragmentActivity的活动不会打破AndroidAnnotations的规则:

1
2
3
4
@EActivity(R.id.main)
public class DetailsActivity extends FragmentActivity {

}

阅读全文 »

@AfterXXX调用顺序

发表于 Apr 6 2015 | 分类于 Android | | 阅读次数

原文地址:
https://github.com/excilys/androidannotations/wiki/%40AfterXXX-call-order

用@AfterXXX标注的方法调用次序

同一个类中的同一个注释的方法调用顺序不能保证,你不应该依赖于它。如果你想多种方法按照可靠的顺序被被调用,你应该只创建创建一个注解的方法,并用它来调用它们所需顺序的其他方法。

阅读全文 »

Injecting Views

发表于 Apr 6 2015 | 分类于 Android | | 阅读次数

原文地址:
https://github.com/excilys/androidannotations/wiki/Injecting-Views

@ViewById

在Activity中@ViewById标注的字段,必须的在activity所在的布局layout中可以找到相应的ID,类似于调用findViewById()方法。
注释的视图id可以设置参数,即@ViewById(R.id.myTextView)。如果没有设置视图id,将使用的名称字段。字段不能是私有的。

阅读全文 »

@EBean增强自定义类

发表于 Apr 6 2015 | 分类于 Android | | 阅读次数

原文地址:
https://github.com/excilys/androidannotations/wiki/Enhance-custom-classes

加强自定义类

您可以在一个不是一个标准的Android组件(如Activity,Service)的类使用注解@EBean。
你只需要使用@EBean注释这个类即可:

1
2
3
4
@EBean
public class MyClass {

}

阅读全文 »

@EApplication增强Application类

发表于 Apr 5 2015 | 分类于 Android | | 阅读次数

译文地址:
https://github.com/excilys/androidannotations/wiki/Enhancing-the-Application-class

加强应用类

您可以使用@EApplication注释来增强Android的Application类:

1
2
3
4
@EApplication
public class MyApplication extends Application {

}

阅读全文 »

@EView@EViewGroup增强自定义视图

发表于 Apr 5 2015 | 分类于 Android | | 阅读次数

译文地址:
https://github.com/excilys/androidannotations/wiki/Enhance-custom-views

如果你想创建自定义组建,可以使用@EView和@EViewGroup的注解方法。

为什么要使用自定义组建?

如果你发现在应用程序中的不同位置的某些布局部分需要复制相同的内容和调用相同的方法,那么自定义组建可以让你的开发轻松很多!

阅读全文 »

AA工作原理及启动Activity的方式

发表于 Apr 5 2015 | 分类于 Android | | 阅读次数

译文地址:
https://github.com/excilys/androidannotations/wiki/HowItWorks#starting-an-annotated-activity

概述

AndroidAnnotations是以一种非常简单的方式工作。它会使用标准的Java注释处理工具自动添加一个额外的编译步骤来生成的”源代码”。
这里所谓的源代码是指,对于每个增强型类,例如每@EActivity注解的Activity,它就会生成一个具有相同名称而且末尾追加一个下划线的子类。

阅读全文 »

@EActivity增强Activity

发表于 Apr 5 2015 | 分类于 Android | | 阅读次数

译文地址:
https://github.com/excilys/androidannotations/wiki/Enhance-activities

阅读全文 »

AS下搭建AGES开发框架

发表于 Apr 5 2015 | 分类于 Android | | 阅读次数

使用AndroidStudio(以下简称AS)作为首选的开发工具已经很普及了,但是作为一个Eclipse的老手来说,转AS还是需要点时间去适应的。比如以前常用的快捷键,代码提示: Alt+/ 在AS下是ctrl+alt+space 而 查看函数则由之前的鼠标悬浮变成了按F2查看,导入包则由之前的ctrl+shift+o编程了现在的alt+enter
说了这么多不适应的快捷键,下面来谈谈如何在AS下搭建AEG开发框架。

阅读全文 »

工厂方法模式

发表于 Apr 4 2015 | 分类于 设计模式 | | 阅读次数

什么是工厂方法模式

首先来看一下Android手机和Iphone手机使用工厂方法是怎么生产的,你就懂了。
工厂模式类图

阅读全文 »

单例模式(Singleton Pattern)

发表于 Apr 4 2015 | 分类于 设计模式 | | 阅读次数

什么是单例模式

首先来看一段单例模式的通用代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
public class Singleton{
//自行实例化
private static final Singleton instance = new Singleton();
/**
*1,构造函数为私有,不能通过new获得对象实例,限制实例产生
*2,自行实例化
*/

private Singleton(){
};
//只能通过调用Singleton来获取其实例
public static Singleton getInstance(){
return instance;
}
//单例模式中的其他方法尽量是static,
public static void otherFuc(){
}
}

阅读全文 »
1234
Mrljdx

Mrljdx

无为,兼爱

58 日志
7 分类
34 标签
RSS
GitHub Weibo
© 2015 - 2017 Mrljdx
由 Hexo 强力驱动
主题 - NexT.Muse