friends I created an dialogfragment which consist of a recyclerview. in that recyclerview I added some image and text.when I select the particular image it should be selected means I want the position of that particulars get to my activity and dialog fragment is dismiss, I go through the various sited but didn't understand. can anyone please tell me,new to the programming.
Thanks in advance
Create a method in your activity that shows the dialog fragment as below
public void onRecyclerItemSelected(int position){
yourDialog.dismiss();
}
To call this method from your dialog fragment, capture click of recycler view using interface from adapter. So whenever recycler view is clicked you can call your activity method from dialog fragment using
if(getActivity()!=null && getActivity() instanceOf YourActivity){
((YourActivity)getActivity().onRecyclerItemSelected(pos);
}
Where pos is the int pos of recycler item clicked. Hope you understand. Any doubts please let me know.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.