diff --git a/samples/ApiDemos/AndroidManifest.xml b/samples/ApiDemos/AndroidManifest.xml index b425eaa11..81dea159e 100644 --- a/samples/ApiDemos/AndroidManifest.xml +++ b/samples/ApiDemos/AndroidManifest.xml @@ -75,7 +75,7 @@ + android:theme="@android:style/Theme.Holo.Dialog"> diff --git a/samples/ApiDemos/res/layout/dialog_activity.xml b/samples/ApiDemos/res/layout/dialog_activity.xml index 2b27d9adc..b3a5689f7 100644 --- a/samples/ApiDemos/res/layout/dialog_activity.xml +++ b/samples/ApiDemos/res/layout/dialog_activity.xml @@ -17,8 +17,28 @@ - - + + + + + + + + + diff --git a/samples/ApiDemos/res/layout/foreground_service_controller.xml b/samples/ApiDemos/res/layout/foreground_service_controller.xml index 20ce10345..076d4a3dc 100644 --- a/samples/ApiDemos/res/layout/foreground_service_controller.xml +++ b/samples/ApiDemos/res/layout/foreground_service_controller.xml @@ -17,9 +17,10 @@ - + App/Activity/Dialog Example of how you can use the Theme.Dialog theme to make an activity that looks like a - dialog. + dialog. It also has lots of text to show how text wrapping (and + corresponding window size adjustment) can happen in a dialog. + Add content + Remove content App/Activity/Custom Dialog Example of how you can use a custom Theme.Dialog theme to make an activity that looks like a @@ -372,7 +375,7 @@ - App/Dialog + App/Alert Dialogs OK Cancel dialog with a message OK Cancel dialog with a long message OK Cancel dialog with ultra long message diff --git a/samples/ApiDemos/src/com/example/android/apis/app/DialogActivity.java b/samples/ApiDemos/src/com/example/android/apis/app/DialogActivity.java index 7441b752a..0a6b72404 100644 --- a/samples/ApiDemos/src/com/example/android/apis/app/DialogActivity.java +++ b/samples/ApiDemos/src/com/example/android/apis/app/DialogActivity.java @@ -19,10 +19,17 @@ package com.example.android.apis.app; // Need the following import to get access to the app resources, since this // class is in a sub-package. import android.app.Activity; +import android.content.Intent; import android.os.Bundle; +import android.view.View; import android.view.Window; +import android.view.View.OnClickListener; +import android.widget.Button; +import android.widget.ImageView; +import android.widget.LinearLayout; import com.example.android.apis.R; +import com.example.android.apis.app.ForegroundService.Controller; /** *

Dialog Activity

@@ -50,5 +57,30 @@ public class DialogActivity extends Activity { getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, android.R.drawable.ic_dialog_alert); + + Button button = (Button)findViewById(R.id.add); + button.setOnClickListener(mAddContentListener); + button = (Button)findViewById(R.id.remove); + button.setOnClickListener(mRemoveContentListener); } + + private OnClickListener mAddContentListener = new OnClickListener() { + public void onClick(View v) { + LinearLayout layout = (LinearLayout)findViewById(R.id.inner_content); + ImageView iv = new ImageView(DialogActivity.this); + iv.setImageDrawable(getResources().getDrawable(R.drawable.icon48x48_1)); + iv.setPadding(4, 4, 4, 4); + layout.addView(iv); + } + }; + + private OnClickListener mRemoveContentListener = new OnClickListener() { + public void onClick(View v) { + LinearLayout layout = (LinearLayout)findViewById(R.id.inner_content); + int num = layout.getChildCount(); + if (num > 0) { + layout.removeViewAt(num-1); + } + } + }; }