【问题标题】:Android widget. Mock view before widget loads安卓小部件。小部件加载之前的模拟视图
【发布时间】:2014-10-28 02:58:01
【问题描述】:

我在主屏幕上有一个简单的小部件。它在手机重启后成功加载,但需要一些时间,在此期间(约 5-10 秒),没有小部件必须存在的视图。

我尝试了其他一些小部件,它们在设备加载后加载了一些模拟的 emty 视图。

如何在设备加载后显示一些视图?

一些屏幕。

重启后。

过了一段时间。

我已经测试了我的提供商收到的回调:

10-27 21:11:29.486    onEnabled
10-27 21:11:29.496    onReceive
10-27 21:11:29.506    onUpdate

所以它们几乎同时发生。

也许有一些(可能是布局)属性为“widgetViewBeforLoaded”或其他?

【问题讨论】:

    标签: android android-widget


    【解决方案1】:

    我已经解决了问题。

    最初小部件仅加载小部件的布局,而不向其中填充任何信息。

    我的小部件布局是:

    <ImageView
        android:id="@+id/backgroundView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"/>
    
    <TextView
        android:id="@+id/widgetText"
        style="@style/widget_text"/>
    

    在这种情况下,wigdets 中没有文本和背景,可以定义默认视图,例如通过将布局更改为:

    <ImageView
        android:id="@+id/backgroundView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="@drawable/rounded_bg"/> <!-- DEFAULT BG !-->
    
    <TextView
        android:id="@+id/widgetText"
        style="@style/widget_text"
        android:text="Loading..."/> <!-- DEFAULT TEXT !-->
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-11-19
      • 2014-05-16
      • 1970-01-01
      • 2017-08-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多