gpt4 book ai didi

Android: View 持有者上的 classCastException

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:44:56 25 4
gpt4 key购买 nike

我有一个适配器,我正在尝试将联系人详细信息检索到 ListView 中

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());

我在我的日志中收到 follogin 错误

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();我哪里做错了,感谢任何帮助

最佳答案

我认为为此返回类型delcare,

return view;

关于Android: View 持有者上的 classCastException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13951726/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com