【发布时间】:2014-05-23 10:01:00
【问题描述】:
PHP / C# / ASP 编码器在给 Xamarin 一个机会后正确地在 android 中开始(然后所有编码中断 6 个月)。
我正在尝试在通知中实现自定义布局。我可以让它产生正常的通知,但是当它使用 setContent(view) 完成时会崩溃。
也是 Eclipse / ADT 的新手,因此很难知道如何自己解决这些问题(在 Visual Studio 中这很容易)。
澄清一下,displayNotification 当前设置为在应用启动时执行。
我确信它是如此简单和小,但是已经很晚了,我的头脑很疲惫。非常感谢所有帮助!
这是我的代码(删除任何注释掉的代码只是为了清理它)。
protected void displayNotification() {
RemoteViews customNotificationView =
new RemoteViews(getPackageName(), R.layout.notification_layout);
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this);
mBuilder.setContent(customNotificationView);
mBuilder.setTicker("New Message Alert!");
mBuilder.setSmallIcon(R.drawable.ic_launcher);
mBuilder.setOngoing(true);
mNotificationManager = (NotificationManager)
getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(notificationID, mBuilder.build());
}
这是我的自定义布局
<?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="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/notification_title"
style="@style/NotificationTitle"
/>
<SeekBar
android:id="@+id/seekBar1"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
【问题讨论】:
标签: android eclipse android-layout notifications remoteview