简体   繁体   English

LayoutInflater类型的方法inflate(int,ViewGroup,boolean)不适用于参数(int,int,boolean)

[英]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。

JAVA: JAVA:

@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;
    }

ERROR: 错误:

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)

ERROR LOCATION: 错误位置:

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. 其他答案表明您应该传递nullconvertView ,这是错误的。

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.

相关问题 错误 java 方法组合Sum(int[], int, List<integer> ) 类型中的解决方案不适用于 arguments (int[], int, boolean)</integer> - error java The method combinationSum(int[], int, List<Integer>) in the type Solution is not applicable for the arguments (int[], int, boolean) 如何阻止LayoutInflater()。inflate(int resource,ViewGroup root,boolean attachToRoot)引发IllegalStateExceptions? - How did I stop IllegalStateExceptions from being thrown with LayoutInflater().inflate(int resource, ViewGroup root, boolean attachToRoot)? TopScoreDocCollector 类型中的方法 create (int, int) 不能用于参数 (int, boolean) - Method create (int, int) in the type TopScoreDocCollector is not capable for the arguments (int, boolean) 类型中的方法不适用于参数(int) - The method in the type is not applicable for the arguments (int) 方法 sum(int, int, int, int) 不适用于参数 (int) - The method sum(int, int, int, int) is not applicable for the arguments (int) 类型X中的方法X不适用于参数(int) - The method X in the type X is not applicable for the arguments (int) ArrayList 类型中的方法 set(int, Int)<int> 不适用于 arguments (int, int) 长度无法解析或不是字段</int> - The method set(int, Int) in the type ArrayList<Int> is not applicable for the arguments (int, int) length cannot be resolved or is not a field main类型的方法(double [])不适用于参数(int []) - The method (double[]) in the type main is not applicable for the arguments (int[]) ArrayBoss 类型中的方法 (int[]) 不适用于参数 () - The method (int[]) in the type ArrayBoss is not applicable for the arguments () FragmentTransaction类型的方法add(int,Fragment)不适用于参数(int,WeatherFragment) - The method add(int, Fragment) in the type FragmentTransaction is not applicable for the arguments (int, WeatherFragment)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM