【发布时间】:2013-02-17 10:13:49
【问题描述】:
我是 Android 开发新手,我已经开始创建这个应用程序,我在其中读取 XML 提要并列出内容。但即使提要发生变化,我仍然会显示相同的数据。尽管一夜之间缓存似乎自行清除。我想在每次启动我的应用程序时强制阅读提要。我尝试了How to clear cache Android 此处描述的方法,但没有帮助。
我的猜测是我必须在我的主要活动中执行 onCreate(至少这是我迄今为止尝试过的)。
谁能指出我正确的方向?
提前致谢:-)
这里有一些代码sn-ps。
来自我的活动:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list_game);
deleteCache(this);
new ReadLeagueXml().execute();
}
deleteCache 是我链接到的另一个线程的方法。
然后在我的 doInBackground 我有
InputStream inputStream = new URL(xmlURL).openStream();
if (inputStream != null) {
list = parse(inputStream);
}
最后在我的 onPostExecute 中:
ListView matchListView = (ListView)findViewById(R.id.match_list);
List<String> matchArray = new ArrayList<String>();
for (int i = 0; i < matches.size(); i++) {
matchArray.add(matches.get(i).HomeTeam + " - " + matches.get(i).AwayTeam);
}
matchArray.toArray();
matchesArrayAdapter = new MatchListAdapter(ListGameActivity.this, matches);
matchListView.setAdapter(matchesArrayAdapter);
【问题讨论】:
-
您能发布更多数据吗?可能是一些代码和更多关于你的应用到底做什么的细节,比如数据分配给 ListView 的位置?
-
添加了代码 sn-p。希望它有所帮助:-/