所以我想显示步数,但这不起作用。
小部件加载但 TextView 没有改变!
public class WidgetDisplay extends AppWidgetProvider {
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds){
super.onUpdate(context, appWidgetManager, appWidgetIds);
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.dwidgitlayout);
SharedPreferences load_steps = context.getSharedPreferences("steps", 0);
int step_value = load_steps.getInt("steps", 0);
views.setTextViewText(R.id.dwidgit_steps, String.valueOf(step_value));
appWidgetManager.updateAppWidget(appWidgetIds, views);
}
}
有任何想法吗?