【发布时间】:2014-01-11 22:55:47
【问题描述】:
我想将当前日期保存到我的列表视图中的文本视图中,我已经设置了所有其他内容,因此无需帮助,只需将日期保存到文本视图我的代码如下,有人可以告诉我有什么问题吗?
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
SharedPreferences.Editor editor = settings.edit();
editor.putLong("time", date.getTime());
editor.commit();
Date date2 = new Date(settings.getLong("time", 0));
【问题讨论】:
-
你遇到了什么错误
-
@tyczj none 它只是不保存日期,而是明天它将我的列表视图中的所有日期设置为明天的日期听起来像我知道的 getView 和 .setText
-
您的代码在我看来没问题。您是否调试过您发布的那部分。我很确定它工作正常。也许问题(ListView 中的日期?)出在其他地方?
标签: android android-listview android-fragments sharedpreferences