I'm attempting to resolve a previous issue with setting fill parameters:
Thumbnail does not fill_parent as expected
however when I attempt to implement the fix provided in the answer I don't think I've implemented it correctly. When I attempt to do so I get an error regarding the inflation argument stating: The method inflate(int, ViewGroup, boolean) in the type LayoutInflater is not applicable for the arguments (int, int, boolean) however I'm not sure the exact parameter I should use to resolve this in order to get the ImageView to fill correctly.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if(convertView == null){
convertView = mInflater.inflate(R.layout.activity_main, R.layout.list_item_user_video, false);
}
UrlImageView thumb = (UrlImageView) convertView.findViewById(R.id.userVideoThumbImageView);
TextView title = (TextView) convertView.findViewById(R.id.userVideoTitleTextView);
final Video video = videos.get(position);
thumb.setImageDrawable(video.getThumbUrl());
title.setText(video.getTitle());
return convertView;
}
The method inflate(int, ViewGroup, boolean) in the type LayoutInflater is not applicable for the arguments (int, int, boolean)
convertView = mInflater.inflate(R.layout.activity_main, R.layout.list_item_user_video, false);
The second parameter to inflate()
needs to be a ViewGroup
. You are passing an int
. Presumably, the second parameter should be parent
.
You should put the parentview in the second argument of the methods signature - that is
mInflater.inflate(R.layout.activity_main, parent, false);
where parent is the ViewGroup
As user2365568 points out, you should pass parent
as the root
parameter. The other answers indicate you should pass null
or the convertView
, which is wrong.
Check out this article about layout inflation, and why the root
parameter is important: http://www.doubleencore.com/2013/05/layout-inflation-as-intended/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.