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

标签 java android view imageview int

我正在尝试通过设置填充参数来解决之前的问题:

Thumbnail does not fill_parent as expected

但是,当我尝试实现答案中提供的修复时,我认为我没有正确实现。当我尝试这样做时,我收到有关通货膨胀参数的错误消息: LayoutInflater 类型中的方法 inflate(int, ViewGroup, boolean) 不适用于参数 (int, int, boolean) 但是我不确定为了让 ImageView 正确填充,我应该使用确切的参数来解决这个问题。

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

错误:

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

错误位置:

convertView = mInflater.inflate(R.layout.activity_main, R.layout.list_item_user_video, false);

最佳答案

inflate() 的第二个参数需要是一个 ViewGroup。您正在传递一个 int。据推测,第二个参数应该是parent

关于java - LayoutInflater 类型中的方法 inflate(int, ViewGroup, boolean) 不适用于参数 (int, int, boolean),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20378394/

相关文章:

android - 在 fragment 中动态添加 TextView

java - Android - setRequestedOrientation - Activity 和 View 生命周期

Java 等待通知,两个线程作为同一个类

java - 有没有理由永远不关闭 JDBC 连接?

android - 适用于 Android 的 Google TV SDK

android - Scrollview 和 layout_constraintHeight_max 使 View 消失

java - 向 JPane 添加操作监听器或 if 语句

java - Hibernate5中的 "Reverse Engineering"功能在哪里?

android - Android 基于跟踪和基于采样的方法分析之间的差异及其对报告的 CPU 时间的影响

javascript - 通过按下按钮加载具有不同数据的相同组件