-3

I've tried different solutions, but I always receive a Non static method error on the setAdapter() call.

ListView SearchList=findViewById(R.id.SearchList);
final ArrayList<String> startDate=new ArrayList<String>();
final ArrayAdapter arrayAdapter_startDate=new ArrayAdapter(this,android.R.layout.simple_list_item_1,startDate);
ParseQuery <ParseObject> searchTrip=ParseQuery.getQuery("Trip");
searchTrip.whereGreaterThanOrEqualTo("Start_Date",findViewById(R.id.StartDate));
      searchTrip.findInBackground(new FindCallback<ParseObject>() {
        @Override
        public void done(List<ParseObject> objects, ParseException e) {
            if (e==null && objects!=null) {

                    for(ParseObject Start_Date: objects) {
                        startDate.add(Start_Date.getString("StartDateInsert"));                                                   }
                ListView.setAdapter(arrayAdapter_startDate);
            } else {e.printStackTrace();}
        }
    });
Mike M.
  • 38,532
  • 8
  • 99
  • 95
  • `ListView.setAdapter(arrayAdapter_startDate);` – Your `ListView` is named `SearchList`. Call `setAdapter()` on that, not on `ListView`: `SearchList.setAdapter(arrayAdapter_startDate);`. – Mike M. Sep 01 '19 at 14:38
  • Maybe a more appropriate dupe: [What is the reason behind "non-static method cannot be referenced from a static context"?](https://stackoverflow.com/q/290884). – Mike M. Sep 01 '19 at 15:34
  • Please don't fundamentally change your question like that, especially after it's been answered. If you have a new issue, please create a new post. – Mike M. Sep 01 '19 at 21:39

1 Answers1

1

You should not create variable name with upper character (your ListView)

Try to replace

ListView.setAdapter(arrayAdapter_startDate);

to

SearchList.setAdapter(arrayAdapter_startDate);
Kien Vu
  • 460
  • 4
  • 8