首页 > 其他分享 >简单试用Android Annotations

简单试用Android Annotations

时间:2023-02-15 11:38:25浏览次数:37  
标签:layout img url Eclipse Annotations 试用 Android com android


Android Annotations号称 "是一个能够加速 Android 开发的开源框架,它可以帮助开发者处理

一些 前后台任务、rest 服务、应用类、代码片段等,让开发者专注于真正重要的东西”。

为了看看实际 效果,今天搭建环境,简单试用了一下(只是跑起来了。。。)

一、准备工作

在 [url]https://github.com/excilys/androidannotations[/url] 下载源码及相关的jar包
按照 [url]https://github.com/excilys/androidannotations/wiki/Eclipse-Project-Configuration [/url]上的步骤配置Eclipse


二、运行Demo
将demo中examples\HelloWorldEclipse目录下的项目导入到Eclipse中,运行良好


三、运行简单工程
1.工程目录
[img]http://dl2.iteye.com/upload/attachment/0093/8234/f3080850-9f65-344c-972b-378bda4148e0.png[/img]
2.配置Eclipse
[img]http://dl2.iteye.com/upload/attachment/0093/8236/024d3588-7b93-3b97-9eb2-b3e3bde4e1cb.png[/img]
[img]http://dl2.iteye.com/upload/attachment/0093/8238/ff9df1ba-3459-3892-ae98-5a77c45128e8.png[/img]
3.代码

import com.googlecode.androidannotations.annotations.EActivity;

import android.app.Activity;

@EActivity(R.layout.activity_first)
public class FirstActivity extends Activity {

}


<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<TextView
android:id="@+id/helloTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="17dp"
android:layout_marginTop="15dp"
android:text="TextView" />

</RelativeLayout>


<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.iaiai.test"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity android:name="com.iaiai.test.FirstActivity_" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>

标签:layout,img,url,Eclipse,Annotations,试用,Android,com,android
From: https://blog.51cto.com/u_15955464/6058964

相关文章