gpt4 book ai didi

java - Android 的未知膨胀错误

转载 作者:行者123 更新时间:2023-11-29 22:01:22 25 4
gpt4 key购买 nike

您好,我的 Android 应用程序有问题。问题是当我尝试设置新 View 时。

    public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
try{
LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.list, null);
}
catch(Exception e){
String a=e.toString();
}
}

行 v = vi.inflate(R.layout.list, null);我得到这个错误:

    android.view.InflateException: Binary XML file line #5: Error inflating class <unknown> 

这也是我的 list.xml 文件:

    <?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="15dp"
android:background="@drawable/bg_seznam" >
<TextView
android:id="@+id/item_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="17dp"
android:textColor="#ffffff"
android:textSize="20dp"
android:textStyle="bold"
android:typeface="serif" >
</TextView>
</TableRow>
</TableLayout>

有什么想法吗?

最佳答案

尝试替换这行代码

v = vi.inflate(R.layout.list, null);

由这个:

v = vi.inflate(R.layout.list, parent, false);

关于java - Android 的未知膨胀错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11847478/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com