java.lang.RuntimeException:无法为片段不同的布局大小绑定视图

时间:2017-12-31 05:53:23

标签: android android-fragments butterknife

我正在尝试为不同的布局创建我的应用程序支持(例如:layout-large-tvdpi).inside layout-large-tvdpi文件夹我已经插入了两个布局(一个布局用于片段的其他活动)。

当我在平板电脑活动布局上运行我的应用程序时显示正常。但是当我移动到片段时,应用程序崩溃并向我显示错误java.lang.RuntimeException: Unable to bind views。它在ButterKnife.bind(this,v)上显示错误

这是我的活动

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test);
        ButterKnife.bind(this);

    }

这是我的片段

 public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View v;
        v = inflater.inflate(R.layout.fragment_home, container, false);        
        ButterKnife.bind(this,v);
        return v;
    }

Log Cat

enter image description here

片段布局

enter image description here

活动布局

enter image description here

1 个答案:

答案 0 :(得分:2)

检查@InjectViews的类型是否正确。我使用ImageView代替LinearLayout。这也许是你的问题。

相关问题