Код фрагмента:
public ListView favoritesList;
CustomListViewAdapter myArrayAdapter;
private List<ListItem> listItems = new ArrayList<ListItem>();
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
ImageButton main_training_button = (ImageButton) getActivity().findViewById(R.id.main_training_button);
main_training_button.setImageResource(R.drawable.ic_active_run_black_24dp);
return inflater.inflate(R.layout.fragment_main, container, false);
favoritesList = (ListView)getActivity().findViewById(R.id.favoritesList);
myArrayAdapter = new CustomListViewAdapter(MainActivity.this,
R.layout.custom_list_view, listItems);
favoritesList.setAdapter(myArrayAdapter);
Код адаптера:
public CustomListViewAdapter(Context context, int resourceId, List<ListItem> items) {
super(context, resourceId, items);
this.context = context;
}
Пробовал getActivity(), getContext(), inflater.getContext(), this, MainActivity.this
. Но не работает
return