以编程方式更改卡片视图可点击属性

问题描述 投票:0回答:0
如何将卡视图查看可点击属性从运行时的true to false更改,例如,当检查“一个单选”按钮时,我想显示新项目和可单击的false,以及当检查“ b”广播按钮时,我想显示具有不同数量项目和可点击的新项目。 我该如何实施? 我试过这个:

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,因为卡片视图对象为空。

android radio-button android-cardview clickable
© www.soinside.com 2019 - 2024. All rights reserved.