我解析片段中的Json數據。爲了得到這個Json數據的視圖,我使用了RecycleView。在這個片段中,我展示了一些帖子的簡短細節。我希望當用戶點擊recycleView時,它會轉到另一個活動並顯示此帖子的詳細信息。如何使我的RecycleView可點擊?如何使RecycleView在片段中可點擊?
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_recent_post, container, false);
recentpostRecycleView = (RecyclerView) view.findViewById(R.id.recent_posts);
recentpostRecycleView.setLayoutManager(new LinearLayoutManager(getActivity()));
recentPostAdapter = new RecentPostAdapter(getActivity());
recentpostRecycleView.setAdapter(recentPostAdapter);
sendJsonRequest();
return view;
}
我RecycleView ScreenShoot:
我發現從slidenard一個解決方案與addOnItemTouchListener。它允許添加onLongTouch。好一個。 – Yeahia2508