您好我正在为微调器使用自定义adaptar,但是当我从微调器中选择一个项目时,没有使用我选择的选项在微调器上设置文本。我究竟做错了什么?以下代码是我的适配器:
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 :(得分: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);
}