<tfoot id='zEcUy'></tfoot>
        <bdo id='zEcUy'></bdo><ul id='zEcUy'></ul>

      <legend id='zEcUy'><style id='zEcUy'><dir id='zEcUy'><q id='zEcUy'></q></dir></style></legend>
      <i id='zEcUy'><tr id='zEcUy'><dt id='zEcUy'><q id='zEcUy'><span id='zEcUy'><b id='zEcUy'><form id='zEcUy'><ins id='zEcUy'></ins><ul id='zEcUy'></ul><sub id='zEcUy'></sub></form><legend id='zEcUy'></legend><bdo id='zEcUy'><pre id='zEcUy'><center id='zEcUy'></center></pre></bdo></b><th id='zEcUy'></th></span></q></dt></tr></i><div id='zEcUy'><tfoot id='zEcUy'></tfoot><dl id='zEcUy'><fieldset id='zEcUy'></fieldset></dl></div>

      <small id='zEcUy'></small><noframes id='zEcUy'>

    1. onUserInteraction 在 DialogPreference 中不起作用

      时间:2023-08-30
        <tbody id='rKqcO'></tbody>

          <small id='rKqcO'></small><noframes id='rKqcO'>

          <tfoot id='rKqcO'></tfoot>

          <legend id='rKqcO'><style id='rKqcO'><dir id='rKqcO'><q id='rKqcO'></q></dir></style></legend>
          <i id='rKqcO'><tr id='rKqcO'><dt id='rKqcO'><q id='rKqcO'><span id='rKqcO'><b id='rKqcO'><form id='rKqcO'><ins id='rKqcO'></ins><ul id='rKqcO'></ul><sub id='rKqcO'></sub></form><legend id='rKqcO'></legend><bdo id='rKqcO'><pre id='rKqcO'><center id='rKqcO'></center></pre></bdo></b><th id='rKqcO'></th></span></q></dt></tr></i><div id='rKqcO'><tfoot id='rKqcO'></tfoot><dl id='rKqcO'><fieldset id='rKqcO'></fieldset></dl></div>
            <bdo id='rKqcO'></bdo><ul id='rKqcO'></ul>
                本文介绍了onUserInteraction 在 DialogPreference 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                预计 onUserInteraction 将被调用以进行任何用户交互.它在 PreferenceActivity 中运行良好.但是,当弹出 DialogPreference 时,即使有触摸事件等用户交互,也不会再调用 onUserInteraction.

                It is expected that onUserInteraction is being called for any user interaction. it works fine in PreferenceActivity. However, when a DialogPreference is popup, onUserInteraction is not called anymore even there is user interaction such as touch event.

                DialogPreference 似乎不是唯一的情况.每当显示 Dialog 时,它都不会将用户交互报告给活动.

                It seems that DialogPreference is not the only case. Whenever Dialog is shown, it does not report the user interaction to activity.

                但是,如果我真的需要它,我该怎么办.谢谢.

                But what can I do if I really need it. Thank You.

                推荐答案

                据我所知,onUserInteraction() 在用户与对话框交互时根本不会被调用(甚至从Activity,您在其中监视交互).

                As far as I know, the onUserInteraction() is simply not called while the user is interacting with a dialog (even started from Activity in which you're monitoring interactions).

                我知道的两个解决方案是:

                Two solutions I know are:

                • 子类 Dialog/DialogPreference 类并覆盖 dispatchTouchEvent().

                实现Window.Callback接口并将其设置为Dialog的窗口回调,发出:

                Implement Window.Callback interface and set it as Dialogs window callback by issuing:

                dialog.getWindow().setCallback(callbackImplementation);
                

                注意:此实现应通过调用适当的对话框方法来处理所有接收到的事件,或以您自己的方式处理事件(例如通过手动调用 onUserInteraction()).

                Note: this implementation should process all received events by calling appropriate dialog methods or handle the events in your own way (e.g. by manually calling onUserInteraction()).

                编辑

                您有几种方法可以从自定义 PreferenceDialog 实例中获取 Activity.

                You have couple of ways to get Activity from the custom PreferenceDialog instance.

                1. 调用返回PreferenceManagerDialogPreference.getPreferenceManager()方法.它有一个 getActivity() 方法 但它是包私有的 所以你必须把你的自定义 DialogPreference 放在 android.preference 包来访问它.

                1. Call DialogPreference.getPreferenceManager() method which returns PreferenceManager. It has a getActivity() method but it's package-private so you would have to put your custom DialogPreference in android.preference package to access it.

                PreferenceActivity.onCreate() 中,填充首选项后,使用 findPreference() 找到您的自定义 DialogPreference钥匙.然后将其转换为您的自定义类并通过访问器将活动设置为 this.

                In the PreferenceActivity.onCreate(), after inflating the preferences, use findPreference() to find your custom DialogPreference by key. Then cast it to your custom class and set activity to this via an accessor.

                我会选择第二个选项.

                这篇关于onUserInteraction 在 DialogPreference 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:如何让主屏幕快捷方式启动对话框? 下一篇:如何在 Android 中将我的活动显示为对话框?

                相关文章

                最新文章

              1. <legend id='V0n9z'><style id='V0n9z'><dir id='V0n9z'><q id='V0n9z'></q></dir></style></legend>

                    <bdo id='V0n9z'></bdo><ul id='V0n9z'></ul>
                  <tfoot id='V0n9z'></tfoot>
                1. <small id='V0n9z'></small><noframes id='V0n9z'>

                  <i id='V0n9z'><tr id='V0n9z'><dt id='V0n9z'><q id='V0n9z'><span id='V0n9z'><b id='V0n9z'><form id='V0n9z'><ins id='V0n9z'></ins><ul id='V0n9z'></ul><sub id='V0n9z'></sub></form><legend id='V0n9z'></legend><bdo id='V0n9z'><pre id='V0n9z'><center id='V0n9z'></center></pre></bdo></b><th id='V0n9z'></th></span></q></dt></tr></i><div id='V0n9z'><tfoot id='V0n9z'></tfoot><dl id='V0n9z'><fieldset id='V0n9z'></fieldset></dl></div>