Android的微调器设置标签 [英] android spinner set tag

查看:181
本文介绍了Android的微调器设置标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发的应用程序。在我从数据库填充微调。我得到了它由描述和code的数组列表。我需要设置code作为标记每个描述。是否有可能增加对中微调各个项目的标签。

I am developing application. In that i am populating spinner from the database. I got the arrayList which consist of description and code . I need to set the code as tag for each description. Is there any possibility to add tag for individual items in spinner.

推荐答案

尝试简单的自定义适配器:

Try simple custom adapter:

    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;
        }

这篇关于Android的微调器设置标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆