I'm having a problem with adapter in Fragment.
My Fragment:
public class HomeActivity extends Fragment {
private final DataBaseHandler db = new DataBaseHandler(getActivity());
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.main, container, false);
return rootView;
}
public void onActivityCreated (Bundle savedInstanceState){
ArrayList<Contact> imageArry = new ArrayList<Contact>();
ContactImageAdapter adapter;
List<Contact> contacts = db.getAllContacts("Bancada");
for (Contact cn : contacts) {
//add contacts data in arrayList
imageArry.add(cn);
}
// linha com erro!
adapter = new ContactImageAdapter(this, R.layout.screen_list,imageArry);
ListView dataList = (ListView) findViewById(R.id.list); // linha com erro!
dataList.setAdapter(adapter);
}
}
Detail in an Activity gives no error.