0

我想创建一个带有名称列表的微调器,以及来自许多 .jpg 的 id 列表

我有一个带有 String[] 的类,其中包含名称,以及带有可绘制对象 ID 的 Integer[]。

我的主要课程是下一个

public class Settings extends Activity{


private Button btnGuardar, btnCerrar;
private Spinner spOperadoras, spTarifas;
private Operadoras op = new Operadoras();


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.settings);


    btnGuardar = (Button)findViewById(R.id.buttonSave);
    btnCerrar = (Button)findViewById(R.id.buttonClose);
    spOperadoras = (Spinner)findViewById(R.id.spinnerOperador);
    spTarifas = (Spinner)findViewById(R.id.spinnerTarifas);

    OperadorAdapter adapter = new OperadorAdapter(this,    R.layout.custom_spinner, op);
    spOperadoras.setAdapter(adapter);
}

}

然后我的适配器是:

public class OperadorAdapter extends BaseAdapter implements SpinnerAdapter{

Activity context;
int spLayoutId;
Operadoras operadoras;

public OperadorAdapter(Activity context, int id, Operadoras op){
    //super(context, id, op);
    this.context = context;
    this.operadoras = op;
    this.spLayoutId = id;

}
@Override
 public View getDropDownView(int position, View convertView, ViewGroup parent) {
     return getCustomView(position, convertView, parent);
 }

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    return getCustomView(position, convertView, parent);
}

public View getCustomView(int position, View convertView, ViewGroup parent) {

    View item = convertView;
    TextView opName;
    ImageView opIcon;

        LayoutInflater inflater = context.getLayoutInflater();
        item = inflater.inflate(spLayoutId, null);
        opName = (TextView) item.findViewById(R.id.nombreOperador);


        opIcon = (ImageView) item.findViewById(R.id.imageOperador);


    opName.setText(operadoras.getOperador(position).toString());
    opIcon.setImageResource(operadoras.getLogo(position));
    return item;
}
@Override
public int getCount() {
    // TODO Auto-generated method stub
    return 0;
}
@Override
public Object getItem(int position) {
    // TODO Auto-generated method stub
    return null;
}
@Override
public long getItemId(int position) {
    // TODO Auto-generated method stub
    return 0;
}

但是我的微调器没有结果。

有什么问题???

谢谢。

4

1 回答 1

0
@Override
public int getCount() {
    // TODO Auto-generated method stub
    return 0;
}

返回您的实际计数。

于 2013-04-18T22:17:40.340 回答