无法通知观看通知

时间:2016-03-31 08:05:39

标签: android push-notification android-notifications

我有2个xml布局呈现为通知:

1)1成功膨胀,1成功膨胀。

2)不膨胀的视图具有以下内容:

<ImageView
    android:id="@+id/bigimage1"
    android:layout_width="match_parent"
    android:layout_height="200dp"
    android:scaleType="centerCrop"
    android:src="@drawable/no_image_transparent"/>

<ImageView
    android:id="@+id/gradient_fg"
    android:layout_width="match_parent"
    android:layout_height="200dp"
    android:scaleType="fitXY"
    android:src="@drawable/gradient"/>

<!-- The custom notification requires a subject field.
To maximize space in this layout this
field is hidden. Visibility is set to gone. -->
<TextView
    android:id="@+id/subject"
    android:text="New notification!"
    android:textAppearance="@android:style/TextAppearance.StatusBar.EventContent"
    android:textSize="16sp"
    android:layout_alignTop="@+id/icon"
    android:layout_toLeftOf="@+id/icon"
    android:layout_alignParentLeft="true"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:maxLines="1"
    android:shadowColor="@color/labelDarkGrey"
    android:shadowRadius="5"
    android:textColor="@color/labelWhite"
    android:visibility="visible"
    android:layout_marginRight="10dp"
    android:layout_marginLeft="10dp"
    android:gravity="right"
    />

<!-- The message block.  This is multiline, with a maximum of 6 lines. -->
<TextView
    android:id="@+id/message"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:maxLines="6"
    android:singleLine="false"
    android:text="You have received a new notification. Why don't you click here to find out what that notification is?"
    android:textAppearance="@android:style/TextAppearance.StatusBar.EventContent"
    android:textSize="14dip"
    android:textColor="@color/labelWhite"
    android:layout_toLeftOf="@+id/icon"
    android:layout_alignParentLeft="true"
    android:shadowColor="@color/labelDarkGrey"
    android:shadowRadius="5"
    android:layout_below="@id/subject"
    android:layout_marginRight="10dp"
    android:layout_marginLeft="10dp"
    android:layout_marginBottom="8dp"
    android:gravity="right"
    />

<ImageView
    android:id="@+id/icon_bg"
    android:layout_width="39dp"
    android:layout_height="39dp"
    android:layout_alignParentRight="true"
    android:layout_marginRight="4dp"
    android:layout_marginLeft="8dp"
    android:layout_marginTop="10dp"
    android:src="@mipmap/ic_launcher" />
<ImageView
    android:id="@+id/icon"
    android:padding="10dp"
    android:layout_width="39dp"
    android:layout_height="39dp"
    android:layout_alignParentRight="true"
    android:layout_marginRight="4dp"
    android:layout_marginLeft="4dp"
    android:layout_marginTop="10dp"
    android:src="@drawable/no_image_transparent" />

<ImageView
    android:id="@+id/small_icon_background"
    android:layout_width="16dp"
    android:layout_height="16dp"
    android:layout_marginBottom="-2dp"
    android:layout_marginRight="-6dp"
    android:layout_alignRight="@+id/icon_bg"
    android:layout_alignBottom="@+id/icon_bg"
    android:src="@drawable/no_image_transparent"
    />

<ImageView
    android:id="@+id/context_icon"
    android:layout_width="16dp"
    android:layout_height="16dp"
    android:padding="2dp"
    android:layout_marginBottom="-2dp"
    android:layout_marginRight="-6dp"
    android:layout_alignRight="@+id/icon_bg"
    android:layout_alignBottom="@+id/icon_bg"
    android:src="@drawable/no_image_transparent"
    />

<LinearLayout
    android:id="@+id/button_container"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:visibility="visible"
    android:layout_below="@+id/bigimage1">
    <Button
        android:id="@+id/button1"
        android:text="Yes"
        android:imeActionLabel="Yes"
        android:textColor="@color/labelWhite"
        android:contentDescription="Yes"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0.5"
        android:background="@color/labelDarkGrey"
        android:visibility="visible">
    </Button>
    <Button
        android:id="@+id/button2"
        android:text="No"
        android:imeActionLabel="No"
        android:textColor="@color/labelWhite"
        android:contentDescription="No"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0.5"
        android:background="@color/labelGrey"
        android:visibility="visible">
    </Button>
    <Button
        android:id="@+id/button3"
        android:text="maybe"
        android:imeActionLabel="No"
        android:textColor="@color/labelWhite"
        android:contentDescription="No"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0.5"
        android:background="@color/labelDarkGrey"
        android:visibility="visible">
    </Button>
</LinearLayout>

我希望停止接收我收到的错误,如下所示:

03-31 09:37:21.691: E/StatusBar(3744): android.content.res.Resources$NotFoundException: Resource ID #0x7f040021
03-31 09:37:21.706: E/AndroidRuntime(32742): FATAL EXCEPTION: main
03-31 09:37:21.706: E/AndroidRuntime(32742): android.app.RemoteServiceException: Bad notification posted from package com.example.exs: Couldn't expand RemoteViews for: StatusBarNotification
....

任何可能导致此问题的想法?

0 个答案:

没有答案