使用另一项活动

时间:2017-12-31 13:03:38

标签: android performance

我有RecyclerView。按下某个项目后,会显示另一个Activity和另一个RecyclerView。问题是第二个Activity需要几秒钟才能加载。我想在Application Activity准备就绪之前使RecyclerView更具响应性,启动Adapter。换句话说,我希望在第二个Activity中花费的加载时间不会在第一个Activity中,因此当用户点击第一个Activity时,第二个Activity会立即出现但没有一秒钟后加载的物品。我看到recyclerView.setAdapter(adapter)Activity之后启动。 设置Adapter后,有没有办法启动private void firstTimeMatchLoader(){ Intent intent = getIntent(); bet = intent.getParcelableExtra("all_match"); uri = intent.getData(); if(bet == null){ Thread loadMatchesFromMemory = new Thread(new Runnable() { @Override public void run() { Cursor c = getContentResolver().query(uri, new String[]{DocumentContentProvider.Columns.OCR_TEXT}, null, null, null); c.moveToFirst(); String text = c.getString(c.getPosition()); HashMatchUtil util = new HashMatchUtil(); allMatch = util.fromStringToArray(text); bet = new SingleBet(allMatch); singleBetAdapter = new SingleBetAdapter(SingleBetActivity.this,bet); singleBetAdapter.setHasStableIds(true); rVSingleBet.setAdapter(singleBetAdapter); allMatchLoadListener.onMatchesLoaded(); singleBetAdapter.setOutsideClickListener(new ActivityClickListener()); singleBetAdapter.setDialogListener(new DialogClickListener()); } }); loadMatchesFromMemory.start(); } else{ allMatch = bet.getArrayMatch(); singleBetAdapter = new SingleBetAdapter(SingleBetActivity.this, bet); singleBetAdapter.setHasStableIds(true); rVSingleBet.setAdapter(singleBetAdapter); allMatchLoadListener.onMatchesLoaded(); singleBetAdapter.setOutsideClickListener(new ActivityClickListener()); singleBetAdapter.setDialogListener(new DialogClickListener()); } }

Java代码

no suitable method found for add(String)
method Collection.add(CAP#1) is not applicable
  (argument mismatch; String cannot be converted to CAP#1)
method List.add(CAP#1) is not applicable
  (argument mismatch; String cannot be converted to CAP#1)
   where CAP#1 is a fresh type-variable:
  CAP#1 extends Object from capture of ?

我希望在创建活动后执行loadMatchesFromMemory线程。

0 个答案:

没有答案