【问题标题】:Kankan.wheel on desktop widgetKankan.wheel 桌面小部件
【发布时间】:2013-08-08 13:20:38
【问题描述】:

kankan.wheel (http://code.google.com/p/android-wheel/) 是我的项目中包含的一个库。

如果我将轮子小部件添加到活动布局中 - 没关系并且工作完美,但如果我将此组件添加到桌面小部件布局中 - 此刻将小部件添加到桌面我有这个:

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

并且小部件不显示,只有字符串:无法显示小部件

我的 XML 布局文件:

<?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>

【问题讨论】:

    标签: android android-wheel


    【解决方案1】:

    桌面小部件有一个limited set of allowed parts。由于允许在主屏幕中执行任意代码存在潜在的安全问题,这些限制是必要的。

    这是 appWidget Docs 的相关部分:

    RemoteViews 对象(因此,App Widget)可以支持以下布局类:

    框架布局

    线性布局

    相对布局

    网格布局

    还有以下小部件类:

    模拟时钟

    按钮

    计时码表

    图像按钮

    图像视图

    进度条

    文本视图

    ViewFlipper

    列表视图

    网格视图

    堆栈视图

    AdapterViewFlipper

    不支持这些类的后代。

    【讨论】:

    • 在这种情况下我该怎么办?我想要不同的布局
    • @alexey 您唯一的选择是使用允许的布局来制作近似模拟或功能相似的设计。
    • 我可以使用 ImageView。我可以在程序代码中初始化我的视图并将我的视图转换为位图。喜欢这个问题:stackoverflow.com/questions/4062559/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-19
    • 2011-05-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多