在状态栏中实现交互式通知(Android)

在状态栏中实现交互式通知(Android),第1张

概述我想知道当用户点击状态栏中的通知时如何禁用突出显示效果,此外,我想允许用户通过按下按钮直接与我在通知中放置的RemoteView进行交互.我知道这可以做到,因为HTC的Sense持续通知,而正在进行的呼叫已经完成了上述目标.如果您有任何想法,请告诉我,具体来说,如何为嵌入在RemoteView

我想知道当用户点击状态栏中的通知时如何禁用突出显示效果,此外,我想允许用户通过按下按钮直接与我在通知中放置的RemoteVIEw进行交互.

我知道这可以做到,因为HTC的Sense持续通知,而正在进行的呼叫已经完成了上述目标.

如果您有任何想法,请告诉我,具体来说,如何为嵌入在RemoteVIEw中的视图设置OnClickListener?

解决方法:

我没有尝试过这个,但它的工作方式与使用RemoteVIEws.setonClickPendingIntent的小部件相同.禁用行选择突出显示的一种方法可能是向外部布局元素添加单击Intent,然后不对其执行任何 *** 作.

例如,如果您的自定义布局如下所示.

<linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"        androID:ID="@+ID/layout_root"        androID:orIEntation="horizontal"        androID:layout_wIDth="fill_parent"        androID:layout_height="fill_parent">    <ImageVIEw androID:ID="@+ID/button"           androID:layout_wIDth="wrap_content"           androID:layout_height="fill_parent"           androID:src="@drawable/button"/>    <TextVIEw androID:ID="@+ID/text"          androID:layout_wIDth="wrap_content"          androID:layout_height="fill_parent"          androID:text="Some Text"  /></linearLayout>

向layout_root添加do_nothing intent,

RemoteVIEws contentVIEw = new RemoteVIEws(getPackagename(), R.layout.yourlayout);notification.contentVIEw = contentVIEw;PendingIntent peClick = PendingIntent.getbroadcast(this, 0, new Intent("com.button_CliCK"), 0);contentVIEw.setonClickPendingIntent(R.ID.button, peClick);PendingIntent penothing = PendingIntent.getbroadcast(this, 0, new Intent("com.DO_nothing"), 0);contentVIEw.setonClickPendingIntent(R.ID.layout_root, penothing);

顺便说一句,HTC能够以普通开发人员无法修改的方式修改androID,因此使用他们的东西作为可能的例子并不总是好的.

总结

以上是内存溢出为你收集整理的在状态栏中实现交互式通知(Android)全部内容,希望文章能够帮你解决在状态栏中实现交互式通知(Android)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1117517.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存