我有一个小部件,当我按下它时会更新,但我想在小部件更新时显示一个进度轮。
//remove text
updateViews.setViewVisibility(R.id.widget_textview, View.GONE);
updateViews.setViewVisibility(R.id.widget_dkk, View.GONE);
// show progress wheel
updateViews.setViewVisibility(R.id.widget_Pross, View.VISIBLE);
// task that take time are locatet here a GetHTTP function
//Show text again
updateViews.setViewVisibility(R.id.widget_textview, View.VISIBLE);
updateViews.setViewVisibility(R.id.widget_dkk, View.VISIBLE);
// Remove progress wheel
updateViews.setViewVisibility(R.id.widget_Pross, View.GONE);
所有这些都位于我的小部件更新类中:
public static RemoteViews buildUpdate(Context context) {
但是进度轮没有显示。这就像小部件只更新一次,因此在 GetHttp 中计算时不显示进度轮。
编辑:
// Remove rext and show progress wheel
updateViews.setViewVisibility(R.id.widget_textview, View.GONE);
updateViews.setViewVisibility(R.id.widget_dkk, View.GONE);
updateViews.setViewVisibility(R.id.widget_Pross, View.VISIBLE);
ComponentName thisWidget = new ComponentName(context, SaldoWidget.class);
AppWidgetManager manager = AppWidgetManager.getInstance(context);
manager.updateAppWidget(thisWidget, updateViews);
// GetHttp code here / long computing task her
//Show text and remove progress wheel
updateViews.setViewVisibility(R.id.widget_textview, View.VISIBLE);
updateViews.setViewVisibility(R.id.widget_dkk, View.VISIBLE);
updateViews.setViewVisibility(R.id.widget_Pross, View.GONE);
manager.updateAppWidget(thisWidget, updateViews);