Load spinner into another

0

I wanted to know how when selecting a spinner item, another spinner is populated with an Adapter. I've tried it this way:

@Override
public void onItemSelected(AdapterView<?> arg0, View arg1, int posicao, long arg3) {

    ArrayAdapter<String> adapter2 
           = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, minhalista);
}

But it does not let you create the Adapter, in my case it can only be in the click because I'm going to pull from a database, and load that list. How do I play the list in spinner2, when a spiner1 item is selected?

    
asked by anonymous 17.12.2014 / 06:43

1 answer

3

In your code, you are passing the callback event to the context. Pass your Activity.

@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
                           int posicao, long arg3) {

    ArrayAdapter<String> adapter2 
           = new ArrayAdapter<String>([SUA ACTIVITY AQUI].this,android.R.layout.simple_spinner_item, minhalista);
}
    
17.12.2014 / 12:50