【问题标题】:how to fix deprecated: startManagingCursor()如何修复已弃用:startManagingCursor()
【发布时间】: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


    【解决方案1】:

    加载程序框架的工作一旦分解就不太难理解。您将需要使用管理器以及一组您自己的自定义回调。这篇文章应该能帮到http://hiqes.com/android-loaders/

    【讨论】:

      猜你喜欢
      • 2023-02-19
      • 1970-01-01
      • 2022-10-22
      • 2016-11-03
      • 2020-02-02
      • 1970-01-01
      • 2015-12-25
      • 1970-01-01
      相关资源
      最近更新 更多