1

kankan.wheel (http://code.google.com/p/android-wheel/) is a library that I include in my project.

If I add wheel widget into activity layout - that's ok and work perfectly, but if I add this component into desktop widget layout - at moment adding widget to desktop I have this:

08-08 21:02:17.630: W/AppWidgetHostView(30529): Error inflating AppWidget       AppWidgetProviderInfo(provider=ComponentInfo{com.snake.vahta.counter/com.snake.vahta.counter.V ahtaAppWidgetProvider}): android.view.InflateException: Binary XML file line #89: Error inflating class kankan.wheel.widget.WheelView

And widget doesn display, only string: Unable to show widget

My XML layout file:

<?xml version="1.0" encoding="utf-8"?>

  <LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:gravity="center"
  android:layout_margin="4dp"
  android:id="@+id/widgetFrameLayout"
  android:background="@drawable/background">


    <LinearLayout
        android:layout_marginTop="24dp"
        android:layout_gravity="center_horizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">

        <kankan.wheel.widget.WheelView android:id="@+id/w_counter_100k"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"/>
        <kankan.wheel.widget.WheelView android:id="@+id/w_counter_10k"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"/>
        <kankan.wheel.widget.WheelView android:id="@+id/w_counter_1k"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"/>
        <kankan.wheel.widget.WheelView android:id="@+id/w_counter_100"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"/>
        <kankan.wheel.widget.WheelView android:id="@+id/w_counter_10"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"/>
        <kankan.wheel.widget.WheelView android:id="@+id/w_counter_1"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"/>
        <kankan.wheel.widget.WheelView android:id="@+id/w_counter_dot"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"/>
        <kankan.wheel.widget.WheelView android:id="@+id/w_counter_01"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"/>
        <kankan.wheel.widget.WheelView android:id="@+id/w_counter_001"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"/>
    </LinearLayout>

    <TextView
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:padding="3dip"
        android:gravity="center"
        android:text="@string/total_sum" />

</LinearLayout>
Machavity
  • 30,841
  • 27
  • 92
  • 100
alexey
  • 127
  • 1
  • 9

1 Answers1

0

Desktop Widgets have a limited set of allowed parts. The restrictions are necessary due to the potential security issues of allowing arbitrary code execution in the home screen.

Here's the relevant part of the appWidget Docs:

A RemoteViews object (and, consequently, an App Widget) can support the following layout classes:

FrameLayout

LinearLayout

RelativeLayout

GridLayout

And the following widget classes:

AnalogClock

Button

Chronometer

ImageButton

ImageView

ProgressBar

TextView

ViewFlipper

ListView

GridView

StackView

AdapterViewFlipper

Descendants of these classes are not supported.

Community
  • 1
  • 1
Collin Flynn
  • 751
  • 6
  • 8
  • And what should I do in this case? I want different layout – alexey Aug 09 '13 at 00:47
  • @alexey Your only option is to work with the allowed layouts to craft an approximate analog, or a functionally similar design. – Collin Flynn Aug 09 '13 at 01:33
  • And I can use ImageView. I can initialize my view in program code and convert my view to bitmap. Like this question: http://stackoverflow.com/questions/4062559/android-appwidget-with-custom-view-not-working – alexey Aug 09 '13 at 01:52