Dynamic Spinners in Android (General Workflow Question)

妖精的绣舞 提交于 2019-12-02 08:36:13

You could try and get the position from your first spinner, the one you've selected and then populate your second spinner after retrieving the proper array based on that position.

You have to listen for your first adapter being changed:

    spinner. setOnItemSelectedListener(new MyOnItemSelectedListener());


class MyOnItemSelectedListener implements OnItemSelectedListener {
    public void onItemSelected(AdapterView<?> parent,
        View view, int pos, long id) {
        String choice = parent.getItemAtPosition(pos).toString();
            populateSecondSpinnerMethod(choice)
       }
    }
    public void onNothingSelected(AdapterView parent) {       // Do nothing.
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!