Permalink
Browse files

Moved about some code, and added Alert examples

Tane Piper <tane@digitalspaghetti.me.uk>
  • Loading branch information...
1 parent bdbbb6c commit a1f93648aebd0ff01938da58d03786177dc44ebe Tane Piper committed Feb 3, 2009
View
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.ifies.android"
- android:versionCode="1"
- android:versionName="1.0.0">
+ android:versionName="1.1" android:versionCode="2">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<meta-data android:value="a14988915c43dd3" android:name="ADMOB_PUBLISHER_ID" />
<activity android:name=".AndroidExamples" android:label="@string/app_name">
@@ -11,13 +10,19 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
- <activity android:name=".AdmobExample" android:label="AdMob Example">
+ <activity android:name=".admob.AdmobExample" android:label="AdMob Example">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
- <activity android:name=".GalleryExample" android:label="Gallery Example">
+ <activity android:name=".gallery.GalleryExample" android:label="Gallery Example">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ </activity>
+ <activity android:name=".alert.AlertExamplesHome" android:label="Alert Example">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -6,13 +6,7 @@
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="bottom">
- <TextView
- android:id="@+id/example_message"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="TextView"
- android:layout_weight="1" />
-
+
<com.admob.android.ads.AdView
android:id="@+id/ad"
android:layout_width="fill_parent"
@@ -21,6 +15,13 @@
app:textColor="#FFFFFF"
app:keywords="Brightroid Brightkite Android"
app:refreshInterval="60"
- android:gravity="bottom"
- android:layout_gravity="bottom"/>
+ android:gravity="top"
+ android:layout_gravity="top"/>
+
+ <TextView
+ android:id="@+id/example_message"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="TextView"
+ android:layout_weight="1" />
</LinearLayout>
View
@@ -0,0 +1,33 @@
+<?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="Alert Dialog Examples"/>
+
+ <Button
+ android:id="@+id/alert1"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:textStyle="bold"
+ android:text="Yes/No Only Alert With Icon"/>
+
+ <Button
+ android:id="@+id/alert2"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:textStyle="bold"
+ android:text="Yes/Cancel/No Alert"/>
+
+ <Button
+ android:id="@+id/alert3"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:textStyle="bold"
+ android:text="OK Alert With Long Text"/>
+</LinearLayout>
View
@@ -22,4 +22,11 @@
android:layout_height="wrap_content"
android:textStyle="bold"
android:text="Gallery Example"/>
+
+ <Button
+ android:id="@+id/example_alerts"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:textStyle="bold"
+ android:text="Alerts Example"/>
</LinearLayout>
View
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
- <string name="hello">Digital Spaghetti's Android Examples</string>
- <string name="app_name">Android Examples</string>
+ <string name="hello">Learning Android Examples</string>
+ <string name="app_name">Learning Android Examples</string>
</resources>
@@ -1,5 +1,9 @@
package org.ifies.android;
+import org.ifies.android.admob.AdmobExample;
+import org.ifies.android.alert.AlertExamplesHome;
+import org.ifies.android.gallery.GalleryExample;
+
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
@@ -59,12 +63,25 @@ public void onClick(View v) {
});
+ example_alerts = (Button) findViewById(R.id.example_alerts);
+ example_alerts.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ // TODO Auto-generated method stub
+ Intent i_Alert = new Intent(AndroidExamples.this, AlertExamplesHome.class);
+ startActivity(i_Alert);
+ }
+
+ });
+
}
private SharedPreferences app_preferences;
private boolean first_run;
private Button example_admob;
private Button example_gallery;
+ private Button example_alerts;
}
@@ -54,18 +54,24 @@ theme attribute (in the form
}
public static final class drawable {
public static final int icon=0x7f020000;
+ public static final int question=0x7f020001;
}
public static final class id {
- public static final int ad=0x7f050001;
- public static final int example_admod=0x7f050003;
- public static final int example_gallery=0x7f050004;
- public static final int example_message=0x7f050000;
- public static final int gallery=0x7f050002;
+ public static final int ad=0x7f050000;
+ public static final int alert1=0x7f050002;
+ public static final int alert2=0x7f050003;
+ public static final int alert3=0x7f050004;
+ public static final int example_admod=0x7f050006;
+ public static final int example_alerts=0x7f050008;
+ public static final int example_gallery=0x7f050007;
+ public static final int example_message=0x7f050001;
+ public static final int gallery=0x7f050005;
}
public static final class layout {
public static final int admob_example=0x7f030000;
- public static final int gallery_example1=0x7f030001;
- public static final int main=0x7f030002;
+ public static final int alert_home=0x7f030001;
+ public static final int gallery_example1=0x7f030002;
+ public static final int main=0x7f030003;
}
public static final class string {
public static final int app_name=0x7f040001;
@@ -1,4 +1,6 @@
-package org.ifies.android;
+package org.ifies.android.admob;
+
+import org.ifies.android.R;
import com.admob.android.ads.AdView;
@@ -14,7 +16,9 @@ public void onCreate(Bundle savedInstanceState) {
this.setContentView(R.layout.admob_example);
example_message = (TextView) findViewById(R.id.example_message);
- example_message.setText("This is an example of AdMob for Android");
+ example_message.setText("This is an example of AdMob for Android.\n\n"
+ + "Please wait while an advert is loaded in to see it in action.\n\n"
+ + "The sourcecode for this application is available from http://android.ifies.org");
example_adview = (AdView) findViewById(R.id.ad);
example_adview.setVisibility(AdView.VISIBLE);
@@ -0,0 +1,104 @@
+package org.ifies.android.alert;
+
+import org.ifies.android.R;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.AlertDialog.Builder;
+import android.content.DialogInterface;
+import android.os.Bundle;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+
+public class AlertExamplesHome extends Activity {
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.alert_home);
+ setupAlerts();
+
+ alert1_button = (Button) findViewById(R.id.alert1);
+ alert1_button.setOnClickListener(new OnClickListener(){
+ @Override
+ public void onClick(View v) {
+ alert1.show();
+ }
+ });
+
+ alert2_button = (Button) findViewById(R.id.alert2);
+ alert2_button.setOnClickListener(new OnClickListener(){
+ @Override
+ public void onClick(View v) {
+ alert2.show();
+ }
+ });
+
+ alert3_button = (Button) findViewById(R.id.alert3);
+ alert3_button.setOnClickListener(new OnClickListener(){
+ @Override
+ public void onClick(View v) {
+ alert3.show();
+ }
+ });
+ }
+
+ private void setupAlerts() {
+ alert1 = new AlertDialog.Builder(AlertExamplesHome.this)
+ .setTitle("Alert Example 1")
+ .setIcon(R.drawable.question)
+ .setMessage("Do you Like this example?")
+ .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int whichButton) {
+ //Put your code in here for a positive response
+ }
+ })
+ .setNegativeButton("No", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int whichButton) {
+ //Put your code in here for a negative response
+ }
+ });
+
+ alert2 = new AlertDialog.Builder(AlertExamplesHome.this)
+ .setTitle("Alert Example 2")
+ .setMessage("Do you want to save this activity?")
+ .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int whichButton) {
+ //Put your code in here for a positive response
+ }
+ })
+ .setNeutralButton("Cancel", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int whichButton) {
+ //Put your code in here for a neutral response
+ }
+ })
+ .setNegativeButton("No", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int whichButton) {
+ //Put your code in here for a negative response
+ }
+ });
+
+ alert3 = new AlertDialog.Builder(AlertExamplesHome.this)
+ .setTitle("Alert Example 3")
+ .setMessage("Lorem ipsum dolor sit amet, consectetur adipiscing elit. "
+ + "Mauris condimentum dolor vitae enim convallis hendrerit.\n\n"
+ + "Vestibulum luctus, risus a porttitor aliquam, tellus libero "
+ + "vulputate tortor, ac feugiat sem risus quis sem. Etiam convallis"
+ + "ullamcorper libero.\n\nAliquam ac mi. Lorem ipsum dolor sit amet, "
+ + "consectetur adipiscing elit. Pellentesque fringilla, neque dictum "
+ + "facilisis molestie, pede ipsum tincidunt tortor, sed mattis lacus arcu "
+ + "et justo.\n")
+ .setNeutralButton("Ok", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int whichButton) {
+ //Put your code in here for a neutral response
+ }
+ });
+ }
+ private Button alert1_button;
+ private Button alert2_button;
+ private Button alert3_button;
+ private Builder alert1;
+ private Builder alert2;
+ private Builder alert3;
+}
@@ -1,4 +1,6 @@
-package org.ifies.android;
+package org.ifies.android.gallery;
+
+import org.ifies.android.R;
import android.app.Activity;
import android.content.Context;

0 comments on commit a1f9364

Please sign in to comment.