如何继承我的自定义主题?

时间:2014-03-14 08:09:41

标签: android dialog styles themes

我需要在服务中提升对话框,我发现设置对话框窗口类型为TYPE_SYSTEM_ALERT可以正常工作:

dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);

但是出现了另一个问题,我在对话框中设置自定义视图,自定义视图中的组件无法继承我的主题样式,它们使用系统默认主题样式。

更新:这是我的示例代码:

public class AlertDialogService extends Service {

@Override
public IBinder onBind(Intent arg0) {
    return null;
}   

@Override
public void onStart(Intent intent, int startId) {
    super.onStart(intent, startId);
    LayoutInflater factory = LayoutInflater.from(this);
    final View textEntryView = factory.inflate(R.layout.alert_dialog_text_entry, null);
    Dialog alertDialog = new AlertDialog.Builder(this, R.style.Theme_My_Dialog_Alert)
        .setTitle(R.string.alert_dialog_text_entry)
        .setView(textEntryView)
        .create();
    alertDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
    alertDialog.show();
}
}

0 个答案:

没有答案