[英]The method inflate(int, ViewGroup, boolean) in the type LayoutInflater is not applicable for the arguments (int, int, boolean)
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.
当我尝试这样做时,我收到有关通货膨胀参数的错误消息,指出:LayoutInflater类型的inflate(int,ViewGroup,boolean)方法不适用于自变量(int,int,boolean),但是我不确定我应该使用确切的参数来解决此问题,以便正确填充ImageView。
@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) LayoutInflater类型的方法inflate(int,ViewGroup,boolean)不适用于参数(int,int,boolean)
convertView = mInflater.inflate(R.layout.activity_main, R.layout.list_item_user_video, false); convertView = mInflater.inflate(R.layout.activity_main,R.layout.list_item_user_video,false);
The second parameter to inflate()
needs to be a ViewGroup
. inflate()
的第二个参数必须是ViewGroup
。 You are passing an int
. 您正在传递一个
int
。 Presumably, the second parameter should be parent
. 大概第二个参数应该是
parent
。
You should put the parentview in the second argument of the methods signature - that is 您应该将parentview放在方法签名的第二个参数中-
mInflater.inflate(R.layout.activity_main, parent, false);
where parent is the ViewGroup 其中parent是ViewGroup
As user2365568 points out, you should pass parent
as the root
parameter. 正如user2365568指出的那样,您应该将
parent
作为root
参数传递。 The other answers indicate you should pass null
or the convertView
, which is wrong. 其他答案表明您应该传递
null
或convertView
,这是错误的。
Check out this article about layout inflation, and why the root
parameter is important: http://www.doubleencore.com/2013/05/layout-inflation-as-intended/ 查看有关布局膨胀以及为什么
root
参数如此重要的本文: http : //www.doubleencore.com/2013/05/layout-inflation-as-intended/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.