-1

I have a problem on a project built up by Android Studio:

@Override
protected void onCreate(Bundle savedInstanceState) {
...
dataAdapter = new GooglePlacesAutocompleteAdapter(MyActivity.this,R.layout.adapter_google_places_autocomplete)
  {
    listView = (ListView) findViewById(R.id.listView1);
    // Assign adapter to ListView
    listView.setAdapter(dataAdapter);
    ...
  }

}

but 'setAdapter' appears in red and a popup message says

Cannot resolve symbol 'setAdapter'

Can anyone help me? Thanks

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115

1 Answers1

0

Judging from the comments already, I am going to give you a suggestion, it might not be perfect since I am not amazing at Android just yet, perhaps instead of using a list view try and use a RecylerView.

I am not sure on your requirements but perhaps I can give you some insight and assist you in solving your problem. Let me try and show you some sample coding, that currently works for me, I am assuming you have everything set up for your adapter and so forth...

private List<ModelForItems> fireflyList = new ArrayList<>();
private MyAdapter sAdapter;

RecyclerView recyclerView = (RecyclerView) findViewById(R.id.my_recycler_view);
sAdapter = new MyAdapter(fireflyList, this);
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getApplicationContext());
recyclerView.setLayoutManager(mLayoutManager);
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setAdapter(sAdapter);

if there is anything you don't understand or if you need any further help please let me know. I hope I did not completely miss your point and am at least able to aid you in some way.

Rookie
  • 115
  • 3
  • 12