Extend DialogActivity API demo to show off new window re-measuring.
Change-Id: Ia04dbf95131d5cffbdd3ae0c22758da7f6d28a1b
This commit is contained in:
@@ -75,7 +75,7 @@
|
|||||||
|
|
||||||
<activity android:name=".app.DialogActivity"
|
<activity android:name=".app.DialogActivity"
|
||||||
android:label="@string/activity_dialog"
|
android:label="@string/activity_dialog"
|
||||||
android:theme="@android:style/Theme.Dialog">
|
android:theme="@android:style/Theme.Holo.Dialog">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.SAMPLE_CODE" />
|
<category android:name="android.intent.category.SAMPLE_CODE" />
|
||||||
|
|||||||
@@ -17,8 +17,28 @@
|
|||||||
<!-- Demonstrates an activity with a dialog theme.
|
<!-- Demonstrates an activity with a dialog theme.
|
||||||
See corresponding Java code com.android.sdk.app.DialogActivity.java. -->
|
See corresponding Java code com.android.sdk.app.DialogActivity.java. -->
|
||||||
|
|
||||||
<!-- This screen consists of a single text field that displays some text. -->
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/text"
|
|
||||||
android:layout_width="match_parent" android:layout_height="match_parent"
|
android:layout_width="match_parent" android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="4dip" android:gravity="center_horizontal">
|
||||||
|
<TextView android:id="@+id/text"
|
||||||
|
android:layout_width="wrap_content" android:layout_height="wrap_content"
|
||||||
android:gravity="center_vertical|center_horizontal"
|
android:gravity="center_vertical|center_horizontal"
|
||||||
android:text="@string/dialog_activity_text"/>
|
android:text="@string/dialog_activity_text"/>
|
||||||
|
<LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal" android:paddingTop="4dip">
|
||||||
|
<Button android:id="@+id/add"
|
||||||
|
android:layout_width="wrap_content" android:layout_height="wrap_content"
|
||||||
|
android:text="@string/dialog_activity_add">
|
||||||
|
<requestFocus />
|
||||||
|
</Button>
|
||||||
|
<Button android:id="@+id/remove"
|
||||||
|
android:layout_width="wrap_content" android:layout_height="wrap_content"
|
||||||
|
android:text="@string/dialog_activity_remove">
|
||||||
|
</Button>
|
||||||
|
</LinearLayout>
|
||||||
|
<LinearLayout android:id="@+id/inner_content"
|
||||||
|
android:layout_width="wrap_content" android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal" android:paddingTop="4dip">
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
|||||||
@@ -17,7 +17,8 @@
|
|||||||
<!-- Demonstrates starting and stopping a local service.
|
<!-- Demonstrates starting and stopping a local service.
|
||||||
See corresponding Java code com.android.sdk.app.LocalSerice.java. -->
|
See corresponding Java code com.android.sdk.app.LocalSerice.java. -->
|
||||||
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:padding="4dip"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="vertical" android:padding="4dip"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:layout_width="match_parent" android:layout_height="match_parent">
|
android:layout_width="match_parent" android:layout_height="match_parent">
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,10 @@
|
|||||||
<string name="activity_dialog">App/Activity/Dialog</string>
|
<string name="activity_dialog">App/Activity/Dialog</string>
|
||||||
<string name="dialog_activity_text">Example of how you can use the
|
<string name="dialog_activity_text">Example of how you can use the
|
||||||
Theme.Dialog theme to make an activity that looks like a
|
Theme.Dialog theme to make an activity that looks like a
|
||||||
dialog.</string>
|
dialog. It also has lots of text to show how text wrapping (and
|
||||||
|
corresponding window size adjustment) can happen in a dialog.</string>
|
||||||
|
<string name="dialog_activity_add">Add content</string>
|
||||||
|
<string name="dialog_activity_remove">Remove content</string>
|
||||||
<string name="activity_custom_dialog">App/Activity/Custom Dialog</string>
|
<string name="activity_custom_dialog">App/Activity/Custom Dialog</string>
|
||||||
<string name="custom_dialog_activity_text">Example of how you can use a
|
<string name="custom_dialog_activity_text">Example of how you can use a
|
||||||
custom Theme.Dialog theme to make an activity that looks like a
|
custom Theme.Dialog theme to make an activity that looks like a
|
||||||
@@ -372,7 +375,7 @@
|
|||||||
<!-- app/dialog examples strings -->
|
<!-- app/dialog examples strings -->
|
||||||
<!-- ============================== -->
|
<!-- ============================== -->
|
||||||
|
|
||||||
<string name="activity_alert_dialog">App/Dialog</string>
|
<string name="activity_alert_dialog">App/Alert Dialogs</string>
|
||||||
<string name="alert_dialog_two_buttons">OK Cancel dialog with a message</string>
|
<string name="alert_dialog_two_buttons">OK Cancel dialog with a message</string>
|
||||||
<string name="alert_dialog_two_buttons2">OK Cancel dialog with a long message</string>
|
<string name="alert_dialog_two_buttons2">OK Cancel dialog with a long message</string>
|
||||||
<string name="alert_dialog_two_buttons2ultra">OK Cancel dialog with ultra long message</string>
|
<string name="alert_dialog_two_buttons2ultra">OK Cancel dialog with ultra long message</string>
|
||||||
|
|||||||
@@ -19,10 +19,17 @@ package com.example.android.apis.app;
|
|||||||
// Need the following import to get access to the app resources, since this
|
// Need the following import to get access to the app resources, since this
|
||||||
// class is in a sub-package.
|
// class is in a sub-package.
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
import android.view.Window;
|
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.R;
|
||||||
|
import com.example.android.apis.app.ForegroundService.Controller;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h3>Dialog Activity</h3>
|
* <h3>Dialog Activity</h3>
|
||||||
@@ -50,5 +57,30 @@ public class DialogActivity extends Activity {
|
|||||||
|
|
||||||
getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON,
|
getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON,
|
||||||
android.R.drawable.ic_dialog_alert);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user