private void setUpDailyRecycleView(List<IWeather> dailyWeathers){
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.daily_recylceview);
CardAdapter cardAdapter = new CardAdapter(this, dailyWeathers);
CardView cardView = (CardView) findViewById(R.id.daily_card);
cardView.setClickable(true);
recyclerView.setAdapter(cardAdapter);
LinearLayoutManager verticalLayoutManger = new LinearLayoutManager(this);
verticalLayoutManger.setOrientation(LinearLayoutManager.VERTICAL);
recyclerView.setLayoutManager(verticalLayoutManger);
}
还有这个:
private void setUpDailyRecycleView(List<IWeather> dailyWeathers){
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.daily_recylceview);
CardAdapter cardAdapter = new CardAdapter(this, dailyWeathers);
recyclerView.setAdapter(cardAdapter);
LinearLayoutManager verticalLayoutManger = new LinearLayoutManager(this);
verticalLayoutManger.setOrientation(LinearLayoutManager.VERTICAL);
recyclerView.setLayoutManager(verticalLayoutManger);
CardView cardView = (CardView) findViewById(R.id.daily_card);
cardView.setClickable(true);
}
但是抛出 NullPointerException,因为卡片视图对象为空。