Hello everyone i need how to passs data from activity to fragment if any easy way
I need to implement by using Interface
Here is the example of my data type.
ArrayList<PreviewData> finaldata = new ArrayList<PreviewData>();
for(int i=0;i<10;i++) {
PreviewData tempdata = new PreviewData("listname"+i+"","dsdsdsd","sdsdsdd");
finaldata.add(tempdata);
}
I am using the dummy values for explaing the code in but my case values coming from web api.
Now problem is i have a activity with two tab . tab1 or tab2
when activity start then it fatch the data from server and store it on custom array list. eg. finaldata in my case
now in tab1 here is a list view that get the list from finaldata
Here is the code of onCreateView Of fragment . i need to pass the final data values from main activity to fragment adapterdata list.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mydbhelper = new DBhelper(getContext());
view = inflater.inflate(R.layout.view_all_campaign, container, false);
ArrayList<PreviewData> adapterdata= new ArrayList<PreviewData>();
listView = (ListView) view.findViewById(R.id.campaign_list_view);
adapter = new MyCustomAdapter(getContext(), R.layout.layout_contact_row, adapterdata);
listView.setAdapter(adapter);
return view;
}