标签:android statusbar notifications
我想知道当用户点击状态栏中的通知时如何禁用突出显示效果,此外,我想允许用户通过按下按钮直接与我在通知中放置的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,statusbar,notifications 来源: https://codeday.me/bug/20190705/1384283.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。