0
我是Android開發人員的初學者,這是我在stackoverflow上的第一篇文章。我想問問,我怎麼能在卡視圖中添加一個點擊事件,以便每當我每張卡上單擊相應的佈局開放如何在卡片視圖上添加onClick事件
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:id="@+id/card_view"
xmlns="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="false"
android:orientation="vertical"
android:padding="12dp">
<ImageView
android:layout_width="150dp"
android:layout_height="150dp"
android:elevation="12dp"
android:src="@drawable/profile"
tools:ignore="ContentDescription,UnusedAttribute" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Arbaz"
android:textSize="20sp"
tools:ignore="HardcodedText" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Arbaz"
android:textSize="18sp"
tools:ignore="HardcodedText" />
</LinearLayout>
也添加你的java文件。上面的一個不是完整的代碼來回答 –