gpt4 book ai didi

android - 如何在小部件中添加加载

转载 作者:行者123 更新时间:2023-11-29 16:10:21 24 4
gpt4 key购买 nike

当我在家里添加我的小部件时,我有几个过程,我如何在它还没有准备好时添加一个“加载图像”?

我看到 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com