有没有人使用RecyclerView找到一种方法来设置一个onClickListener项目RecyclerView?我想为每个项目的每个布局设置一个监听器,但这似乎有点太麻烦我确信有一种方法RecyclerView可以听取这个onClick事件,但我无法弄明白.
我是Android编程的新手,正在开发卡片布局.我想知道,如何让它可点击?
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground"
Run Code Online (Sandbox Code Playgroud)
我在我的卡片小部件上有这个,然后我想知道在哪里点击可点击的动作?我希望能够单击该卡,它获取卡的ID,然后显示新的意图活动
这是我加载适配器的活动的代码
setContentView(R.layout.activity_my);
RecyclerView recList = (RecyclerView) findViewById(R.id.cardList);
recList.setHasFixedSize(true);
LinearLayoutManager llm = new LinearLayoutManager(this);
llm.setOrientation(LinearLayoutManager.VERTICAL);
recList.setLayoutManager(llm);
ContactAdapter ca = new ContactAdapter(createList(30));
recList.setAdapter(ca);
Run Code Online (Sandbox Code Playgroud)