Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/196.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 自定义微调器集文本_Android_Android Spinner_Android Adapter - Fatal编程技术网

Android 自定义微调器集文本

Android 自定义微调器集文本,android,android-spinner,android-adapter,Android,Android Spinner,Android Adapter,您好,我正在为微调器使用自定义适配器,但当我从微调器中选择一个项目时,不会在微调器上设置带有所选选项的文本。我做错了什么?以下代码是我的适配器: private class ListadapterUnicaCidades extends BaseAdapter { private LayoutInflater mInflater = null; private ArrayList<HashMap<String, String>

您好,我正在为微调器使用自定义适配器,但当我从微调器中选择一个项目时,不会在微调器上设置带有所选选项的文本。我做错了什么?以下代码是我的适配器:

 private  class ListadapterUnicaCidades extends BaseAdapter {
            private LayoutInflater mInflater = null;
            private ArrayList<HashMap<String, String>> _list1;
            public ListadapterUnicaCidades(Context context, ArrayList<HashMap<String, String>> pperguntalist) {
                // Cache the LayoutInflate to avoid asking for a new one each time.
                mInflater = LayoutInflater.from(context);
                _list1 = cidadeslist;
            }

            /**
             * The number of items in the list is determined by the number of
             * speeches in our array.
             * 
             * @see android.widget.ListAdapter#getCount()
             */
            public int getCount() {

                // return BabbleMainListParse.getNumOfBabbles();
                return _list1.size();
            }

            /**
             * Since the data comes from an array, just returning the index is
             * sufficent to get at the data. If we were using a more complex data
             * structure, we would return whatever object represents one row in the
             * list.
             * 
             * @see android.widget.ListAdapter#getItem(int)
             */
            public Object getItem(int position) {
                return _list1.get(position);
            }

            /**
             * Use the array index as a unique id.
             * 
             * @see android.widget.ListAdapter#getItemId(int)
             */
            public long getItemId(int position) {

                return position;
            }

            /**
             * Make a view to hold each row.
             * 
             * @see android.widget.ListAdapter#getView(int, android.view.View,
             *      android.view.ViewGroup)
             */
            public View getView(int position, View convertView, ViewGroup parent) 
            {

                Log.d("disponiveislist", "getView");
                // A ViewHolder keeps references to children views to avoid
                // unneccessary calls
                // to findViewById() on each row.
                ViewHolder holder;

                // When convertView is not null, we can reuse it directly, there is
                // no need
                // to reinflate it. We only inflate a new View when the convertView
                // supplied
                // by ListView is null.
                if (convertView == null) 
                {


                    convertView = mInflater.inflate(android.R.layout.simple_list_item_single_choice, parent,false);
                    Log.d("ConvertView",convertView.toString());

                    // Creates a ViewHolder and store references to the two children
                    // views
                    // we want to bind data to.
                    holder = new ViewHolder();
                    holder.listtexto = (TextView) convertView.findViewById(android.R.id.text1);


                    convertView.setTag(holder);
                }
                else 
                {
                    // Get the ViewHolder back to get fast access to the TextView
                    holder = (ViewHolder) convertView.getTag();
                }

                // Bind the data efficiently with the holder.
                //holder.txtVilleListTitle.setText(VilleMainListParse.getMsgTitle(position));


             Log.d("_List", _list1.toString());
             holder.listtexto.setText(_list1.get(position).get("DESIGNACAO"));

                return convertView;
            }

             class ViewHolder
            {
                TextView listtexto;

            }
        } 
第1点

你的电脑没有使用pperguntalist

public ListadapterUnicaCidades(Context context, ArrayList<HashMap<String, String>> pperguntalist) {

还是一样。是否可以更改android.layout?
public Object getItem(int position) {
                return _list1.get(position).get("DESIGNACAO");//_list1.get(position);
            }