如何在android中点击cardView clickable false?

时间:2016-11-14 12:02:01

标签: android android-cardview clickable

Android-developers.blogspot.com API提供 cardView.setClickble(false)方法来设置可点击的false,但无法为CardView解析此方法。

2 个答案:

答案 0 :(得分:0)

将Cardview对象设为cardview,然后设置属性

Cardview Cardview;
cardView.setClickble(false); 

确保在build.gradle

中添加了依赖项
dependencies {
    // CardView
    compile 'com.android.support:cardview-v7:23.3.+'
}

答案 1 :(得分:0)

导入CardView

import android.support.v7.widget.CardView;

然后正确实例化,然后拨打setClickable

// Instead of getContext() you might need to use another method.
// Also, if you have the CardView in a xml, use findViewById.
CardView cardView = new CardView(getContext());
cardView.setClickable(false);