您的位置:首页 > 移动开发 > Android开发

懒人必备之Android效率开发框架(伪原创)

2015-08-29 19:14 465 查看
在网上看到一个好的框架,记录一下,防止以后忘记了

这个框架貌似给我减少了很多不必要的代码,不过好像其中也有些不能满足的,以后靠自己去补充吧

我使用的是intellij idea ,配置android studio 情况是一样的

第一要下载两个包

一个是:androidannotations-3.2.jar

还有是:androidannotations-api-3.2.jar

下载地址:http://androidannotations.org/

配置

把androidannotations-api-3.2.jar引用进去工程

在setting 中找Comiler -> Annotations Processor ,选择Enable annotation processing ,在Processor path 找到现有的androidannotations-3.2.jar文件

Store generated sources relative to 有两个选择,我们选择Module content root

在Activity中类上面加上@EActivity (R.layout.xxx),去掉onCreate 中的setContent 如:

@EActivity (R.layout.main)
public class MyActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//        setContentView(R.layout.main);
}
}


在AndroidMainfest.xml 注册的activity 名字需要变为

<application android:label="@string/app_name" android:icon="@drawable/ic_launcher">
<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>


类名后面加下划线

编译一下 在Module 的Sources 多出一个generated ,这个时候需要把这个引用到工程里面去,类似src和gen 一样

到现在一起ok
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: