作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我在家里添加我的小部件时,我有几个过程,我如何在它还没有准备好时添加一个“加载图像”?
我看到 Youtube 小部件有这个。
谢谢!
最佳答案
我成功了! =)
我不知道这是不是最好的方法,让我告诉你:
在我的小部件 xml 上,我添加了第二个布局,它包含进度条:
widget_layout.xml
<LinearLayout android:id="@+id/progressLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar android:id="@+id/widgetProgressBar" android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
我在我的原始布局上放置了以下代码:
android:visibility="gone"
然后,当我的所有过程结束时,我这样做了:
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget_layout);
remoteViews.setViewVisibility(R.id.progressLayout, View.GONE);
remoteViews.setViewVisibility(R.id.layout, View.VISIBLE);
appWidgetManager.updateAppWidget(widgetId, remoteViews);
如果有人有更好的方法,请告诉我们!
关于android - 如何在小部件中添加加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13961242/
我是一名优秀的程序员,十分优秀!