Dynamic update of Spinner2 based on choice in Spinner 1

前端 未结 2 587
终归单人心
终归单人心 2021-01-24 06:50

In using this code (adapted from here) I get the following error:

The constructor ArrayAdapter(new AdapterView.OnItemSelectedListener(){}, int, String

2条回答
  •  梦毁少年i
    2021-01-24 07:05

    In the constructor to your new ArrayAdapter on the following line:

    ArrayAdapter beAdapter = new ArrayAdapter(this,
    

    this points to the current instance of the OnItemSelectedListener class you are in and not the parent view, this is where the problem occurs because ArrayAdapter does not have a matching constructor. You should try using MyParentView.this (where MyParentView is the name of the view you are in) instead to pass the appropriate instance.

提交回复
热议问题