gpt4 book ai didi

android - 将基于 Material 的对话框主题与 AppCompat 一起使用

转载 作者:IT老高 更新时间:2023-10-28 23:01:37 27 4
gpt4 key购买 nike

我的 list 中有一个 Activity ,我曾经使用对话框主题设置样式。我在 AppCompat 库中找不到如何替换它。

  <activity
android:name=".LoginActivity"
android:theme="@android:styles/Theme.Holo.Dialog"
android:configChanges="orientation|screenSize|keyboardHidden"
android:label="Login" >

是否有基于 Material 的等价物?

最佳答案

Java 代码

    AlertDialog.Builder builder =
new AlertDialog.Builder(SecondActivity.this, R.style.AppCompatAlertDialogStyle);
builder.setTitle("SCRUM");
builder.setMessage("In the SCRUM methodology a sprint is the basic unit of development. Each sprint is preceded by a planning meeting, where the tasks for the sprint are identified and an estimated commitment for the sprint goal is made, and followed by a review or retrospective meeting where the progress is reviewed and lessons for the next sprint are identified. During each sprint, the team creates finished portions of a product.....");
builder.setPositiveButton("OK", null);//second parameter used for onclicklistener
builder.setNegativeButton("Cancel", null);
builder.show();

使用这个主题

  <style name="AppCompatAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="colorAccent">#FFCC00</item>
<item name="android:textColorPrimary">#FFFFFF</item>
<item name="android:background">#5fa3d0</item>
</style>

导入支持 v7 警报对话框

import android.support.v7.app.AlertDialog;

这样的输出,

enter image description here

关于android - 将基于 Material 的对话框主题与 AppCompat 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26554600/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com