6

我有一个适配器,我试图将联系人详细信息检索到列表视图中

public View getView(int position, View convertView, ViewGroup parent) { 

    View view = convertView; 
    final ViewHolder holder;
    if (view == null) { 
    view = inflater.inflate(R.layout.profile, null); 
    holder = new ViewHolder();
    holder.text = (TextView) view.findViewById(R.id.name);
    holder.textContNo = (TextView) view.findViewById(R.id.contactno);
    holder.textEmailId = (TextView) view.findViewById(R.id.emailId); 
    view.setTag(holder);
    } else
        holder = (ViewHolder) view.getTag();


    Profile contact = listCont.get(position); 
    holder.text.setText(contact.getName()); 

    QuickContactBadge photo = (QuickContactBadge ) view.findViewById(R.id.quickContactBadge1);  
    photo.setTag(contact.getMobileNo()); 
    new LoadImage(photo).execute(contact.getMobileNo()); 

我的日志中出现以下错误

FATAL EXCEPTION: main
12-19 17:07:27.080: E/AndroidRuntime(6988): java.lang.ClassCastException: org.appright.myneighborhood.data.Profile cannot be cast to org.appright.myneighborhood.adaptor.ProfileAdapter$ViewHolder
12-19 17:07:27.080: E/AndroidRuntime(6988):     at org.appright.myneighborhood.adaptor.ProfileAdapter.getView(ProfileAdapter.java:82)
12-19 17:07:27.080: E/AndroidRuntime(6988):     at android.widget.AbsListView.obtainView(AbsListView.java:1949)
12-19 17:07:27.080: E/AndroidRuntime(6988):     at android.widget.ListView.measureHeightOfChildren(ListView.java:1228)

在这条线附近得到classcastexception:holder = (ViewHolder) view.getTag(); 我做错了,任何帮助表示赞赏

4

1 回答 1

0

我想所以返回类型 delcare ,

return view;
于 2012-12-19T13:00:42.080 回答