我在访问Asynctask 时遇到问题,该类在A类内部,并且A类具有适配器(RecyclerViewAdapter),该适配器想访问扩展Asynctask 的类简而言之,它是这样的:public class MainActivity extends AppCompatActivity implements View.OnClickListener{ RecyclerView recyclerView; SimpleRecyclerAdapter simpleRecyclerAdapter; LinearLayoutManager linearLayoutManager = new LinearLayoutManager(MainActivity.this); recyclerView.setAdapter(SimpleRecyclerAdapter); public class getData extends AsyncTask<>{ .... }}这是SimpleRecyclerAdapterpublic class SimpleRecyclerAdapter extends RecyclerView.Adapter<SimpleRecyclerAdapter.VersionViewHolder> {//from this I would like to execute getData class} (adsbygoogle = window.adsbygoogle || []).push({}); 最佳答案 这样尝试public class MainActivity extends AppCompatActivity implements View.OnClickListener{RecyclerView recyclerView;SimpleRecyclerAdapter simpleRecyclerAdapter;LinearLayoutManager linearLayoutManager = new LinearLayoutManager(MainActivity.this);new GetData().execute();}public class SimpleRecyclerAdapter extends RecyclerView.Adapter<SimpleRecyclerAdapter.VersionViewHolder> { //from this I would like to execute getData class}public class GetData extends AsyncTask<>{ @Override protected void onPreExecute() { super.onPreExecute(); } @Override protected Void doInBackground(Void... voids) { return null; } @Override protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); recyclerView.setAdapter(new SimpleRecyclerAdapter()); }} (adsbygoogle = window.adsbygoogle || []).push({});
10-06 06:49