Java android的未知充气错误
嗨,我的android应用程序有问题。问题是当我尝试设置新视图时Java android的未知充气错误,java,android,Java,Android,嗨,我的android应用程序有问题。问题是当我尝试设置新视图时 public View getView(int position, View convertView, ViewGroup parent) { View v = convertView; if (v == null) { try{ LayoutInflater vi = (LayoutInflater) getSystemService(Context
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行充气(R.layout.list,空);我得到这个错误:
android.view.InflateException: Binary XML file line #5: Error inflating class <unknown>
android.view.InflateException:二进制XML文件行#5:膨胀类时出错
这也是我的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);
我尝试了你的代码,在我这方面效果很好。
也许做一次清理会有帮助:项目->清理->选择你的项目->确定。可绘制的外观如何?它是图像还是xml绘图?哇,我在另一部手机上试过了,它工作正常。。。我现在想知道为什么它在第一部手机上不工作:Sbtw第一部是2.1 amd第二部是2.2我的这是个问题吗?应用程序的最低级别为7级,它的构建级别为15级。