【发布时间】:2014-11-22 23:38:39
【问题描述】:
我是 Android 编程新手,正在研究卡片布局。我想知道,我如何使它可以点击?
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground"
我的卡片小部件上有它,然后我想知道在哪里放置可点击操作?我希望能够点击卡片,它获取卡片的 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);
【问题讨论】:
-
也许你可以从这里得到一些想法 -> stackoverflow.com/questions/24471109/recyclerview-onclick
-
查看此链接,了解 RecyclerView 上的点击监听器 stackoverflow.com/a/48643276/7319704
标签: android cardlayout