だから、私がやったことは以下の通りである:
私に上記のビューを含むfeed.xml
ファイルには、全体のビューに対してid
を設定しました。それから私はid
こととhereからItemView.java
を使用使用:
だから、
feed.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/home_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/grey_100"
android:orientation="vertical"
android:weightSum="4"
tools:context="com.example.shamsad.tutionhub.activities.FeedActivity">
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:id="@+id/tbHome"
android:background="@color/colorPrimary"
app:titleTextColor="@color/grey_100">
</android.support.v7.widget.Toolbar>
<com.mindorks.placeholderview.InfinitePlaceHolderView
android:id="@+id/loadMoreView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
ItemView.java
@Click(R.id.rootView)
public void onCardClick() {
Intent intent = new Intent(mContext, DetailActivity.class);
intent.putExtra("title", mInfo.getTitle());
intent.putExtra("caption", mInfo.getCaption());
intent.putExtra("salary", mInfo.getSalary());
intent.putExtra("routine", mInfo.getRoutine());
intent.putExtra("time", mInfo.getTime());
Log.d("sajid", "onClick");
mContext.startActivity(intent);
}
を、このonCardClick()
方法では、クリック可能なIDは、このコード@Click(R.id.rootView)
によって設定されます。それだけです。基本的にはcard-view
全体をクリック可能なものに設定します。
また、この偉大な図書館の作者Janisher Aliのおかげで、私は彼に連絡し、彼は多くの助けをしてくれました。
Thisはすばらしい図書館です。 RecyclerView
よりもずっといいです。あなたはそれを試してみることができます:)
実際には、画像ビューが大きいので、それは実際には画像ビューだけで動作します。私の場合、カード全体のリスナーを設定したいのですが。 – sphoenix
コンポーネントをクリック可能/トゥッチに設定し、イベントを消費するカード内のコンポーネントがないことを確認してください。 –
何も動作していません – sphoenix