Android Dialog Activity Demo
1. Android project 추가
2. DialogDemos.java 수정
package sncap.android.apis;
import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import sncap.android.apis.R;
public class DialogDemos extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_LEFT_ICON);
setContentView(R.layout.dialog_activity);
getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON,
android.R.drawable.ic_dialog_alert);
}
}
import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import sncap.android.apis.R;
public class DialogDemos extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_LEFT_ICON);
setContentView(R.layout.dialog_activity);
getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON,
android.R.drawable.ic_dialog_alert);
}
}
3. layout/ dialog_activity.xml 추가
<TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/text"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:gravity="center_vertical|center_horizontal"
android:text="Dialog Demo Test"/>
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:gravity="center_vertical|center_horizontal"
android:text="Dialog Demo Test"/>
4. AndroidManifest.xml 수정
Dialog 관련 Activity 추가
<activity android:name=".DialogDemos"
android:label="@string/app_name"
android:theme="@android:style/Theme.Dialog">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
android:label="@string/app_name"
android:theme="@android:style/Theme.Dialog">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
5. values/ styles.xml 추가
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Dialog" parent="android:style/Theme.Dialog">
<item name="android:windowBackground">@drawable/filled_box</item>
</style>
</resources>
<resources>
<style name="Theme.Dialog" parent="android:style/Theme.Dialog">
<item name="android:windowBackground">@drawable/filled_box</item>
</style>
</resources>
6. res/ drawable 폴더 추가
7. res/drawable/ filed_box.xml 추가
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#f0600000"/>
<stroke android:width="3dp" color="#ffff8080"/>
<corners android:radius="3dp" />
<padding android:left="10dp" android:top="10dp"
android:right="10dp" android:bottom="10dp" />
</shape>
<solid android:color="#f0600000"/>
<stroke android:width="3dp" color="#ffff8080"/>
<corners android:radius="3dp" />
<padding android:left="10dp" android:top="10dp"
android:right="10dp" android:bottom="10dp" />
</shape>
실행..