Answer the question
In order to leave comments, you need to log in
Why does it refer to TextView and how to fix it?
Implemented the list. Everything worked.
I wanted to add a preview and then I got an error:
Fragment code:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
if (convertView == null) {
LayoutInflater vi = (LayoutInflater)getSystemService( Context.LAYOUT_INFLATER_SERVICE);
convertView = vi.inflate(R.layout.person_info, null);
holder = new ViewHolder();
holder.name = (TextView) convertView.findViewById(R.id.name);
holder.preview = (ImageView) convertView.findViewById(R.id.preview); // Error
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
Persons person = personsList.get(position);
holder.name.setText(person.getName());
holder.tracks.setText(person.getTracks());
holder.albums.setText(person.getAlbums());
holder.genres.setText(person.getGenres());
// holder.preview.setText(person.getGenres()); // The temporary line
return convertView;
}
Answer the question
In order to leave comments, you need to log in
Apparently, you declared the preview as a TextView in the holder, but it should be as an ImageView. Apparently.
what is holder.preview for you?
In the view you have R.id.preview as described?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question