I am trying to implement an onItemClick within a fragment, when clicking on an element, but I have no result yet someone can help me?
public class FotoFragment extends Fragment {
private List<DataPictures> mediaList = new ArrayList<>();
private RecyclerView mRecyclerView;
private MediaRVAdapter adapter;
public FotoFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_blank, container, false);
mRecyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
mRecyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 3));
mRecyclerView.setPadding(10,10,10,10);
mRecyclerView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
Toast.makeText(v.getContext(), "Intent onLongClick= ", Toast.LENGTH_SHORT).show();
return false;
}
});
return view;
}
this is my xml fragment_blank
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v7.widget.RecyclerView>
I'm trying to make a multiselection photography power but I've seen that you can do it with the onItemClick method, doing so
public void onItemClick(AdapterView parent, View view, int position, long id) {
How can I get the position of that element? With the onLongClick method?