【发布时间】:2015-05-19 12:34:08
【问题描述】:
我有一个绝望的代码
startManagingCursor(timelineCursor)
该代码不再起作用,但是我必须如何使用 loadmanager 更改我的代码,我已经阅读了一些博客,但我仍然感到困惑。可以举个例子吗?
这是我的完整代码
setContentView(R.layout.timeline);
try {
homeTimeline = (ListView)findViewById(R.id.homeList);
//instantiate database helper
timelineHelper = new NiceDataHelper(this);
//get the database
timelineDB = timelineHelper.getReadableDatabase();
//query the database, most recent tweets first
timelineCursor = timelineDB.query("home", null, null, null, null, null, "update_time DESC");
startManagingCursor(timelineCursor);
//instantiate adapter
timelineAdapter = new UpdateAdapter(this, timelineCursor);
//this will make the app populate the new update data in the timeline view
homeTimeline.setAdapter(timelineAdapter);
//instantiate receiver class for finding out when new updates are available
niceStatusReceiver = new TwitterUpdateReceiver();
//register for updates
registerReceiver(niceStatusReceiver, new IntentFilter("TWITTER_UPDATES"));
Toast.makeText(getApplicationContext(), "teest", Toast.LENGTH_SHORT).show();
//start the Service for updates now
this.getApplicationContext().startService(new Intent(this.getApplicationContext(), TimeLineService.class));
}
catch(Exception te) { Log.e(LOG_TAG, "Failed to fetch timeline: " + te.getMessage()); }
【问题讨论】:
标签: android android-loadermanager android-loader