Why The constructor ArrayAdapter(new View.OnKeyListener(){}, int, String[]) is undefined

前端 未结 4 1367
南笙
南笙 2021-01-18 01:54

Why The constructor ArrayAdapter(new View.OnKeyListener(){}, int, String[]) is undefined in following my coding. This coding is for fetching data from SQLite when typing wor

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-18 02:40

    You need to qualify the use of this when you want to refer to the enclosing class of an inner class. In your code, if the enclosing class is your Activity subclass (let's say it's called MyActivity), then you would write:

    ArrayAdapter adapter = new ArrayAdapter(MyActivity.this,
       R.layout.autosuggest,
       countries);
    

提交回复
热议问题