I realise that this is a duplicate of other previous threads on this issue, However I have read them and I cannot for the life of me work out how to deal with the issue of 'Non-static method 'getItemAtPosition' cannot be referenced from a static context.'
Here is my code:
public class Favourites extends Insulter {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.favourites);
ArrayList<String> favs = getIntent().getStringArrayListExtra("favs");
ListAdapter theAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, favs);
ListView listView = (ListView) findViewById(R.id.favsList);
listView.setAdapter(theAdapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String copyFav = String.copyValueOf(AdapterView.getItemAtPosition(position));
myClip = ClipData.newPlainText("copyFav", copyFav);
myClipboard.setPrimaryClip(myClip);
Toast.makeText(getApplicationContext(), R.string.copied, Toast.LENGTH_SHORT).show();
}
});
}
}