0
我已经使用https://github.com/moondroid/CoverFlow实现了Coverflow ViewPager它运行良好,但OnClick事件不适用于适配器。我尝试了很多,但没有成功,任何人有任何想法呢?OnClick事件在coverflow中不起作用
我的代码看起来像下面
适配器点击收听
viewHolder.txtBookNow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent mIntent = new Intent(activity,ActivityDetail.class);
activity.startActivity(mIntent);
}
});
适配器XML是
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:foreground="@drawable/cover_selector">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:src="@mipmap/simple_banner" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="15dp"
android:orientation="vertical">
<TextView
android:id="@+id/txtPackage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Package"
android:textColor="#0288D1"
android:textSize="12sp"
android:textStyle="bold" />
<TextView
android:id="@+id/txtBookNow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dp"
android:background="@drawable/rounded_corner"
android:padding="5dp"
android:text="Book Now"
android:textColor="#ffffff"
android:textSize="10sp"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>
</FrameLayout>
我已经在CoverFlow上使用了这个OnClick,但是我想执行单击TextView窗体适配器。 – Komal
okey ..比你尝试删除setOnItemClickListener比单击textview? –
是的,我已经删除了CoverFlow的setOnItemClickListener,并在Adapter中添加了OnClickListener。 – Komal