自定义对话框样式:activity_direction.xml
Activity样式:activity_main.xml
Activity代码:
mButtonSetDirection.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View view) {
showDirectionDialog();
}
});
protected void showDirectionDialog() {
final Dialog dialog = new Dialog(MainActivity.this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.activity_direction);
final Button button_submit = (Button)dialog.findViewById(R.id.button_submit);
final Button button_reset = (Button)dialog.findViewById(R.id.button_reset);
button_submit.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View view) {
clearSpinner();
myView.onRedraw();
dialog.dismiss();
}
});
button_reset.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View view) {
dialog.dismiss();
}
});
dialog.show();
}
将Activity伪装成对话框:
设置Activity的Dialog风格,在MainActivity里注册下第二个Activity吧
<activity android:name=".testDialog" android:label="这是一个Activity变成的Dialog" android:theme="@android:style/Theme.Dialog" ></activity>