1
我正在开发应用程序。在这我从数据库中填充微调。我得到了由描述和代码组成的arrayList。我需要将代码设置为每个描述的标记。是否有可能为微调器中的单个项目添加标签。android spinner set tag
我正在开发应用程序。在这我从数据库中填充微调。我得到了由描述和代码组成的arrayList。我需要将代码设置为每个描述的标记。是否有可能为微调器中的单个项目添加标签。android spinner set tag
尝试简单的自定义适配器:
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;
}
谢谢。我也会尝试这个 – noname 2012-02-15 13:47:50
你用什么接口? – Natali 2012-02-15 13:32:43
我使用arrayAdapter – noname 2012-02-15 13:33:27
尝试编写您的custon适配器。 – Natali 2012-02-15 13:35:00