How to add onClick event on card view [closed]

…衆ロ難τιáo~ 提交于 2019-12-04 22:22:58

If you want to trigger anything when user clicks the card, you need to put a OnClickListener on the card.

CardView card_view = (CardView) findViewById(R.id.card_view); // creating a CardView and assigning a value.

card_view.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // do whatever you want to do on click (to launch any fragment or activity you need to put intent here.)
        }
    });
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!