消息中带有集成按钮的警报对话框

发布于 2024-12-06 04:42:51 字数 200 浏览 0 评论 0原文

我想在 AlertDialog (它必须弹出)中执行类似服务条款的操作,用户必须滚动到底部才能看到“接受”或可能伴随的拒绝按钮。有没有办法在 AlertDialog 的 MESSAGE 中包含用户必须滚动浏览的按钮?

类似地,另一种实现就是让按钮无法按下,直到用户滚动到底部,我该怎么做?

洞察力赞赏!

I want to do something like Terms of Service in an AlertDialog (it must pop up) where the user has to scroll to the bottom to see the "accept" or possible an accompanying decline button. Is there a way to include buttons in the AlertDialogs MESSAGE that the user must scroll through?

Similarly another implementation would just be to have the button unpressable until the user scrolls to the bottom, how would I do that?

Insight appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

绝對不後悔。 2024-12-13 04:42:51

我想您总是可以创建一个自定义Dialog并显示它。 Android 开发者网站上有关于如何执行此操作的指南:
http://developer.android.com/guide/topics/ui/dialogs .html#CustomDialog

另一种方法是创建一个具有自己布局的常规类,然后将主题设置为对话框主题。打开时它看起来像一个对话框,并且提供与任何其他 Activity 几乎相同的功能。

I suppose you could always create a custom Dialog and show that. There's a guide on how to do that on the Android developer site right here:
http://developer.android.com/guide/topics/ui/dialogs.html#CustomDialog

An alternative would be to create a regular class with its own layout and then set the theme to the dialog theme. This will look like a dialog when opening, and allows for pretty much the same functionality as any other Activity.

无声无音无过去 2024-12-13 04:42:51

我相信您可以做的是,将对话框中最后一项(即文本视图)的底部位置与 onScrollChanged 侦听器中滚动视图的底部进行比较。这样,当用户到达底部时,您可以调用

 AlertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true);

I believe what you can do is, compare the bottom position of the last item in the dialog, which would be the textview, to the bottom of the scrollview in the onScrollChanged listener. This way, when the user has reached the bottom, you can call

 AlertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true);
橘亓 2024-12-13 04:42:51

给你:

AlertDialog.Builder dBuilder = new AlertDialog.Builder(this);
dBuilder.setMessage(msg)
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which) {
        dialog.dismiss();
    }
    })
.setPositiveButton("Accept", new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which) {
    /// YOUR OK PART
});
AlertDialog alert = dBuilder.create();
alert.show();

显然 msg 包含你的...消息:)

Here you go:

AlertDialog.Builder dBuilder = new AlertDialog.Builder(this);
dBuilder.setMessage(msg)
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which) {
        dialog.dismiss();
    }
    })
.setPositiveButton("Accept", new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which) {
    /// YOUR OK PART
});
AlertDialog alert = dBuilder.create();
alert.show();

Obviously msg contains your... message :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文