2012-07-04 62 views
0

你好我正在使用微調器的自定義微調器,但是當我從微調控制器中選擇一個項目時,沒有文本與我選擇的選擇設置在微調器上。我究竟做錯了什麼?下面的代碼是我的適配器:自定義微調器設置文本

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; 

      } 
     } 

回答

0

點1

您沒有使用pperguntalist

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

點2:當且僅當你想設置你sppiner列表使用所看到的

public Object getItem(int position) { 
       return _list1.get(position).get("DESIGNACAO");//_list1.get(position); 
      } 
+0

它仍然是一樣的。有沒有可能改變android.layout? – user1437481