我有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线程。