Recyclerview没有填入asynctask android

时间:2017-11-10 06:02:55

标签: android-asynctask android-recyclerview

我有两个方法需要在android.First中异步运行我想运行getContactsList()然后populateList()。我试图使用Asynctask但它跳过了recyclerview填充代码,然后打印下一行在onCreate中运行良好时记录。请帮助我

 private class TaskOne extends AsyncTask<Void, Void, Void> {

    @Override
    protected Void doInBackground(Void... params) {
        Log.i("do in background", "running");
        getContactList();
        return null;
    }

    @Override
    protected void onPostExecute(Void aVoid) {
        super.onPostExecute(aVoid);
        pDialog.cancel();
        Log.i("onPostExecute", "running");
        populateList();
        isContacts_fetched();
        Log.i("populateList", "finished");


    }
}

调用onCreate()方法

new TaskOne().execute();

populateList()代码

 public void populateList() {

Log.i(“填充列表”,“已输入”);

//        Toast.makeText(this,String.valueOf(Common.selectedContactNos.size()),Toast.LENGTH_LONG).show();
   displayRecyclerAdapter = new DisplayRecyclerAdapter(DisplayContacts.this);
   LinearLayoutManager mLinearLayoutManager = new LinearLayoutManager(this);
    recyclerView_contacts.setAdapter(displayRecyclerAdapter);
   recyclerView_contacts.setLayoutManager(mLinearLayoutManager);
   displayRecyclerAdapter.notifyDataSetChanged();
}

0 个答案:

没有答案