First of all, if you add Guice and Roboguice libraries to your project.
Download Roboguice and Guice-2.0-no_aop.jar (not guice-3.0), or download
Create a new Android project, such as Guicedemo, the target platform Android1.5 above.
In general, you can add a Lib directory under the project, copy two jar files to the Lib directory, and then pass: Project > Properties > Java build Path > Libraries > Add External J ARs
After adding references to the Guice and roboguice libraries, you can start writing the first example that uses Roboguice.
Steps to use Roboguice:
1. Create a roboapplication subclass Guiceapplication,guiceapplication as a subclass of appliacation, so you need to modify the Androidmanifest.xml, Point the name of the application to this class. See Android Simple development tutorial nine: Creating an application framework
<application android:name= "Guiceapplication"
android:icon= "@drawable/icon" android:label= "@string/app_name" >
<activity android:name= ". Guicedemo "
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>
2. In this simple example, it uses the layout definition as follows:
<?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:id= "@+id/hello"
Android:layout_width= "Fill_parent"
android:layout_height= "Wrap_content"
android:text= "@string/hello"
/>
</linearlayout>
We have defined a textview, and its ID is hello.
Assuming that this application uses a igreetingservice, it has a method getgreeting () returns a string, as for Igreetingservice How to implement, Guidedemo does not need to care.