Permalink
Browse files

Intents - launching an Activity from another

  • Loading branch information...
1 parent 1d8ea58 commit cb8080bd4b2069dcd317f52b16e5b0065de70ae7 Mike Wolfson committed Dec 3, 2012
View
1 AndroidManifest.xml
@@ -22,6 +22,7 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
+ <activity android:name="DetailActivity"></activity>
</application>
</manifest>
View
BIN picture_symbol-web.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN res/drawable-hdpi/picture_symbol.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN res/drawable-ldpi/picture_symbol.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN res/drawable-mdpi/picture_symbol.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN res/drawable-xhdpi/picture_symbol.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
58 res/layout/activity_detail.xml
@@ -0,0 +1,58 @@
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_marginLeft="8dp"
+ android:layout_marginRight="8dp"
+ android:orientation="vertical" >
+
+ <TextView
+ android:id="@+id/detail_title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/expense_item"
+ android:layout_marginTop="8dp"
+ android:textStyle="bold" />
+
+ <TextView
+ android:id="@+id/detail_expense_title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_below="@+id/detail_title"
+ android:text="@string/details_example_text" />
+
+ <TextView
+ android:id="@+id/detail_tax_checkbox"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_below="@+id/detail_expense_title"
+ android:layout_marginTop="8dp"
+ android:text="@string/tax_deductable" />
+
+ <CheckBox
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_below="@+id/detail_expense_title"
+ android:layout_toRightOf="@+id/detail_tax_checkbox" />
+
+ <Button
+ android:id="@+id/detail_enter"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentRight="true"
+ android:layout_below="@+id/detail_tax_checkbox"
+ android:drawableLeft="@drawable/enter_symbol"
+ android:layout_marginTop="8dp"
+ android:text="@string/enter" />
+
+ <Button
+ android:id="@+id/detail_picture"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_below="@+id/detail_tax_checkbox"
+ android:layout_toLeftOf="@+id/detail_enter"
+ android:drawableLeft="@drawable/picture_symbol"
+ android:layout_marginTop="8dp"
+ android:text="@string/receipt" />
+
+</RelativeLayout>
View
4 res/values/strings.xml
@@ -10,5 +10,9 @@
<string name="item_amount">Item Amount:</string>
<string name="expense_amount_hint">Expense Amount</string>
<string name="enter">Enter</string>
+ <string name="expense_item">Expense Item:</string>
+ <string name="details_example_text">Example text : $11.11</string>
+ <string name="tax_deductable">Tax Deductable?</string>
+ <string name="receipt">Receipt</string>
</resources>
View
27 src/com/andevcon/bootcamp/DetailActivity.java
@@ -0,0 +1,27 @@
+/**
+ *
+ */
+package com.andevcon.bootcamp;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.Menu;
+
+/**
+ *
+ */
+public class DetailActivity extends Activity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_detail);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.activity_main, menu);
+ return true;
+ }
+}
View
3 src/com/andevcon/bootcamp/MainActivity.java
@@ -2,6 +2,7 @@
import android.os.Bundle;
import android.app.Activity;
+import android.content.Intent;
import android.text.Editable;
import android.util.Log;
import android.view.Menu;
@@ -26,6 +27,8 @@ public void onClick(View v) {
String amount = expenseAmount.getText().toString();
Log.v("Bootcamp", "The expense: " + name + " has the value: " + amount);
+ Intent details = new Intent(MainActivity.this, DetailActivity.class);
+ startActivity(details);
}
});

0 comments on commit cb8080b

Please sign in to comment.