Android 2.3.3 で通知を作成しようとしています。カスタム レイアウトが必要ですが、Notification Builder を使用できません。通知のレイアウトは次のとおりです。
R.layout.notification_upload
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/relative_notification_upload"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/imageview_icon"
android:layout_height="match_parent"
android:layout_marginRight="10dp"
android:layout_centerVertical="true"
android:src="@drawable/ic_launcher"
android:contentDescription="@string/icon" >
</ImageView>
<ProgressBar
android:id="@+id/progress_bar"
style="@android:style/Widget.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:indeterminate="true" >
</ProgressBar>
</RelativeLayout>
これは、通知のコードです。
NotificationManager notificationManager = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
Intent intent = new Intent(context, HomeActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
intent, 0);
RemoteViews contentView = new RemoteViews(context.getPackageName(), R.layout.notification_upload);
Notification notification = new Notification();
notification.when = 0;
notification.icon = R.drawable.ic_launcher;
notification.contentIntent = pendingIntent;
notification.contentView = contentView;
notificationManager.notify(0, notification);
私は得ています:パッケージから投稿された悪い通知:RemoteViewsを展開できませんでした... どこが間違っていますか? 通知内で ImageView を使用できますか?