Problem with glowpadview with xml

I have a problem with glowpadview in the XML layout file.

My layout code:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:glowpad="http://schemas.android.com/apk/com.fima.glowpadview"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >

<com.fima.glowpadview.GlowPadView
    android:id="@+id/glow_pad_view"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:layout_gravity="center_vertical"
    android:layout_marginBottom="@dimen/glowpadview_margin_bottom"
    android:focusable="true"
    android:gravity="center"
    glowpad:directionDescriptions="@array/snooze_dismiss_direction_descriptions"
    glowpad:feedbackCount="1"
    glowpad:glowRadius="@dimen/glowpadview_glow_radius"
    glowpad:handleDrawable="@drawable/ic_alarm_alert_touch_handle"
    glowpad:innerRadius="@dimen/glowpadview_inner_radius"
    glowpad:outerRadius="@dimen/glowpadview_target_placement_radius"
    glowpad:outerRingDrawable="@drawable/ic_alarm_alert_outerring"
    glowpad:pointDrawable="@drawable/ic_lockscreen_glowdot"
    glowpad:snapMargin="@dimen/glowpadview_snap_margin"
    glowpad:targetDescriptions="@array/snooze_dismiss_descriptions"
    glowpad:targetDrawables="@array/snooze_dismiss_drawables"
    glowpad:vibrationDuration="20" />

I get the following error:

The following classes could not be instantiated:

- com.fima.glowpadview.GlowPadView (Open Class, Show Error Log)
See the Error Log (Window > Show View) for more details.
Tip: Use View.isInEditMode() in your custom views to skip code when shown in Eclipse

java.lang.IllegalStateException: Must specify at least one target drawable
    at com.fima.glowpadview.GlowPadView.<init>(GlowPadView.java:247)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(    at sun.reflect.NativeConstructorAccessorImpl.newInstance(    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(    at java.lang.reflect.Constructor.newInstance(    at com.android.ide.eclipse.adt.internal.editors.layout.ProjectCallback.instantiateClass(ProjectCallback.java:442)
    at com.android.ide.eclipse.adt.internal.editors.layout.ProjectCallback.loadView(ProjectCallback.java:194)
    at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:206)
    at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:131)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:756)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:728)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:373)

How to resolve this?

+4
source share
1 answer

There is an attribute that: glowpad:targetDrawablesthat causes the problem, this attribute must be defined in addition to providing at least one valid target value.

And as I see it, you have already defined it: glowpad:targetDrawables="@array/snooze_dismiss_drawables"so the problem is in the file snooze_dismiss_drawables, which, I believe, definitely contains all the null values, such as:

<array name="snooze_dismiss_drawables">
    <item>@null</item>
    <item>@null</item>
    <item>@null</item>
    <item>@null</item>
</array>

, , , GlowPad , , drawable, , :

<array name="snooze_dismiss_drawables">
    <item>@android:color/transparent</item>
    <item>@null</item>
    <item>@android:color/transparent</item>
    <item>@null</item>
</array>
0

All Articles