M
M
miklce2015-12-04 19:23:34
Android
miklce, 2015-12-04 19:23:34

How to pass context to adapter inside fragment?

I'm trying to put json in the listview, there are plenty of examples, but I do it all in a fragment and not in an activity... I've had a
lot of problems when creating an adapter:
MySimpleAdapter sAdapter = new MySimpleAdapter(this, data, R.layout.item, from, to );
listView.setAdapter(new ArrayAdapter(this, R.layout.page_search, items));
ArrayAdapter simpleAdapter = new SimpleAdapter(this, listView, android.R.layout.simple_list_item_1)
Everything leads to one thing - SimpleAdapter cannot be applied
as I understood the error when passing the context, Google advised getActivity (), but the elements are in the current fragment...
ZY Probably the question is stupid, but I've been struggling for 3 hours trying to put the data in the listview

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
aol-nnov, 2015-12-04
@miklce

getActivity().getApplicationContext(), no?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question