I have listview with some listadapter after click on item from list I’d like to reload list with new data, change adapter’s contests.
I use this in setOnItemClickListener, but I get error: “Type The constructor ArrayAdapter(new AdapterView.OnItemClickListener(){}, int, ArrayList) is undefined”
list.setAdapter(new ArrayAdapter<String>(this, R.layout.simple_list_item_1,Data.user.getChosen_rest()));
How should I do this correctly?
Glendon’s answer is probably the right one. Nevertheless, in case you really need to change the adapter for some reason, you need to pass the right
Contextinstance to the first argument of the constructor.You can extend OnClickListener and add a field mContext to it, to which you will assign the current Activity. Then , use it as:
Alternatively, if the listener is an inner class of the Activity, you can use: