【问题标题】:Can't create aspect for Android dialogs using AspectJ无法使用 AspectJ 为 Android 对话框创建方面
【发布时间】:2016-04-12 22:18:26
【问题描述】:

我已经能够在视图中找到 OnClickListener:

@After("execution(* android.widget.AdapterView.OnItemClickListener.onItemClick(..))")

以及关于活动的事件:

@After("execution(* android.app.Activity.onResume(..))")

但由于某种原因,我似乎无法抓住 AlertDialog、Dialog 甚至 Dialog.Builder 中的任何内容。我想在显示对话框时添加建议。

没用:

@After("execution(* android...AlertDialog.show(..))")

没用:

@After("execution(* android.app.ProgressDialog.show(..))")

没用:

@After("execution(* *..DialogInterface+.*(..) || * *..Dialog+.*(..))")

我会想如果我可以为视图和活动编写方面,我可以为 AlertDialogs 做同样的事情。我仍然认为是我对 AspectJ 的有限了解导致我无法在这里获得好运?

【问题讨论】:

    标签: android dialog aop aspectj android-alertdialog


    【解决方案1】:

    问题在于,Aspects 只能应用于您编写的代码。所以确实,它可以应用于您自己的活动和 OnItemClickListener 实现,但如果您不自己创建 Dialog 的子类,它将使用用户设备上可用的类,这不会应用您的建议。

    【讨论】:

      猜你喜欢
      • 2012-04-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-12
      • 1970-01-01
      • 1970-01-01
      • 2015-02-03
      相关资源
      最近更新 更多