0

我有一个简单的应用程序,它有一个视图和一个应该返回 ListView 的类。除非我重构,否则应用程序可以正常工作,而且我重构的不仅仅是重命名类的名称。一切似乎都已正确更改,但应用程序抛出异常:android.view.InflateException: Binary XML file line #2: Error inflating class

如果我重构回原来的名称,一切都很好。我缺少什么没有被重命名?

代码是

package com.mynamespace.more.views;

import com.mynamespace.more.QTEvent;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.CheckedTextView;
import android.widget.LinearLayout;

public class MyListItem extends LinearLayout {

    private QTEvent qtEvent;
    private CheckedTextView checkbox;

    public MyListItem(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        checkbox = (CheckedTextView)findViewById(android.R.id.text1);
    }

    public void setQTEvent(QTEvent q) {
        this.qtEvent = q;
        checkbox.setText(q.getName());
        checkbox.setChecked(q.isComplete());
    }

    public QTEvent getEvent() {
        return qtEvent;
    }

}
4

1 回答 1

0

It would appear that some layout XML is still referencing the old name. The error will tell you which file and line this is occurring on.

You might also need to do an Eclipse Project -> Force Clean, or ant clean from the command line, to get rid of earlier editions of pre-compiled classes and whatnot.

于 2010-04-23T11:24:37.290 回答