我正在开发应用程序。因为我从数据库填充微调器。我得到了包含描述和代码的arrayList。我需要将代码设置为每个描述的标记。是否有可能在微调器中为单个项添加标记。
答案 0 :(得分:2)
尝试简单的自定义适配器:
public class MySpinnerAdapter extends BaseAdapter {
private Activity context;
public CitiesSpinnerAdapter(Activity context){
this.context=context;
}
@Override
public int getCount() {
return 0;
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
RelativeLayout item= (RelativeLayout)context.getLayoutInflater().inflate(R.layout.<your spinner item layout name>, null);
//set your data to layout components
item.setTag(<your tag object>);
return item;
}