是否可以使用微调项设置标签。我想将我的 bean 对象设置为每个微调项的标签,这可能吗?
最佳答案
希望这对你有帮助:
如下所示创建您自己的 CustomAdapter 并在 getView()
方法中添加标签..
自定义适配器:
public class MySpinnerAdapter extends BaseAdapter {
private Activity context;
public MySpinnerAdapter (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;
}
}
关于Android:如何使用微调项设置标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20902102/