Android- Multiple Spinners

后端 未结 2 1751
無奈伤痛
無奈伤痛 2020-12-31 09:36

I have this code:

package lijap.app.starcraft2counters;

import java.io.File;
import android.app.Activity;
import android.os.Bundle;
import android.os.Enviro         


        
2条回答
  •  天命终不由人
    2020-12-31 09:49

    You could share the adapter between different Spinners if they adapted the same information. Clearly each of your adapters need to adapt a different set of Strings, so you need to create an ArrayAdapter for each Spinner.

    A single OnItemSelectedListener will work for the 3 Spinners (as long as you set them). You can call getId() on the AdapterView passed as an argument to know which Spinner raised the event.

    public void onItemSelected(AdapterView arg0, View arg1, int arg2,
            long arg3) {
        switch(arg0.getId()){
            case R.id.s_answertime:
                break;
            case ...
        }
    }
    

提交回复
热议问题