Javascript Appcelerator通知CreateRemoteView单击事件侦听器
我正在尝试建立一个音乐播放器,我需要有通知托盘中的音乐控制。 我正在为此使用RemoteView,但无法为播放/暂停、下一个和上一个添加事件侦听器。 下面是源代码 custom_layout.xmlJavascript Appcelerator通知CreateRemoteView单击事件侦听器,javascript,titanium,titanium-alloy,Javascript,Titanium,Titanium Alloy,我正在尝试建立一个音乐播放器,我需要有通知托盘中的音乐控制。 我正在为此使用RemoteView,但无法为播放/暂停、下一个和上一个添加事件侦听器。 下面是源代码 custom_layout.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_p
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="@drawable/gradient_background"
android:orientation="vertical" >
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal" >
<ImageView
android:id="@+id/icon_logo"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_marginTop="5dp"
android:layout_marginLeft="20dp"
android:src="@drawable/app_logo_notification"/>
<TextView android:id="@+id/lbl_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14dp"
android:textColor="#b8a25e"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:text="TEST" />
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginTop="10dp"
android:orientation="horizontal" >
<TextView android:id="@+id/message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18dp"
android:textColor="#b8a25e"
android:layout_marginLeft="20dp"
android:text="Now Playing James Bond anthem"/>
<ImageView
android:id="@+id/icon_previous"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginLeft="20dp"
android:src="@drawable/icon_previous_home"/>
<ImageView
android:id="@+id/icon_play"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginLeft="20dp"
android:src="@drawable/ic_action_playback_play"/>
<ImageView
android:id="@+id/icon_next"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginLeft="20dp"
android:src="@drawable/icon_next_home"/>
</LinearLayout>
</LinearLayout>
如有任何建议,我们将不胜感激。有一个完整的远程视图通知示例,网址为:
具有按钮和单击事件的功能 在您的示例中,它应该是:
customLayout.setOnClickPendingIntent(Ti.App.Android.R.id.icon_play, onClickCallback);
function onClickCallback(){}
我已经试过了,它会使应用程序崩溃。SetOnClickPendingEvent需要挂起的意图
customLayout.setOnClickPendingIntent(Ti.App.Android.R.id.icon_play, onClickCallback);
function onClickCallback(){}