Commits

Spencer Herzberg committed 3b288d5

added roboguice depend; implementing a RoboActivity and some simple functionality

Comments (0)

Files changed (3)

 <?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
     <modelVersion>4.0.0</modelVersion>
-    
+
     <groupId>com.example</groupId>
     <artifactId>helloworld</artifactId>
     <version>1.0</version>
         <maven.compiler.target>5</maven.compiler.target>
         <abs.version>4.0.1</abs.version>
     </properties>
-    
+
     <dependencies>
 
         <dependency>
             <scope>provided</scope>
         </dependency>
 
+        <dependency>
+            <groupId>org.roboguice</groupId>
+            <artifactId>roboguice</artifactId>
+            <version>2.0</version>
+        </dependency>
+
         <!--<dependency>-->
-            <!--<groupId>com.actionbarsherlock</groupId>-->
-            <!--<artifactId>library</artifactId>-->
-            <!--<version>${abs.version}</version>-->
-            <!--<type>apklib</type>-->
+        <!--<groupId>com.actionbarsherlock</groupId>-->
+        <!--<artifactId>library</artifactId>-->
+        <!--<version>${abs.version}</version>-->
+        <!--<type>apklib</type>-->
         <!--</dependency>-->
 
         <!--&lt;!&ndash; https://github.com/rtyley/roboguice-sherlock &ndash;&gt;-->
         <!--<dependency>-->
-            <!--<groupId>com.github.rtyley</groupId>-->
-            <!--<artifactId>roboguice-sherlock</artifactId>-->
-            <!--<version>1.1</version>-->
+        <!--<groupId>com.github.rtyley</groupId>-->
+        <!--<artifactId>roboguice-sherlock</artifactId>-->
+        <!--<version>1.1</version>-->
         <!--</dependency>-->
 
     </dependencies>
                         <platform>18</platform>
 
                     </sdk>
-                    
+
                     <!-- All of these go into the /src/main/android/ directory, we don't want to polute the project root directory. -->
                     <androidManifestFile>${project.basedir}/src/main/android/AndroidManifest.xml</androidManifestFile>
                     <resourceDirectory>${project.basedir}/src/main/android/res</resourceDirectory>
                     <assetsDirectory>${project.basedir}/src/main/android/assets</assetsDirectory>
                     <nativeLibrariesDirectory>${project.basedir}/src/main/android/native</nativeLibrariesDirectory>
                     <resourceOverlayDirectory>${project.basedir}/src/main/android/overlay</resourceOverlayDirectory>
-                    
+
                     <!-- Read the Android Maven plugin documentation about these settings -->
                     <undeployBeforeDeploy>true</undeployBeforeDeploy>
 
             </plugin>
         </plugins>
     </build>
-    
+
 </project>

src/main/android/res/layout/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="Hello World, HelloWorldActivity"
-    />
+              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="Hello World, HelloWorldActivity"
+            />
+
+    <Button
+            android:id="@+id/toast"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:text="Toast"
+            />
+
 </LinearLayout>
 

src/main/java/com/example/HomeActivity.java

 package com.example;
 
-import android.app.Activity;
+import android.content.Context;
 import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+import android.widget.Toast;
+import roboguice.activity.RoboActivity;
+import roboguice.inject.ContentView;
+import roboguice.inject.InjectView;
+
+@ContentView(R.layout.main)
+public class HomeActivity extends RoboActivity {
+
+    @InjectView(R.id.toast)
+    private Button toaster;
 
-public class HomeActivity extends Activity {
-    /**
-     * Called when the activity is first created.
-     */
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-        setContentView(R.layout.main);
+
+        toaster.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                Context context = getApplicationContext();
+                Toast toast = Toast.makeText(context, "This is a toast br0!", Toast.LENGTH_LONG);
+                toast.show();
+            }
+        });
     }
+
 }