سؤال

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>
هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top