如题:我在主线程(UI线程)中可以使用LayoutInflater的inflate(int resource, ViewGroup root)方法,来实例化resource对应的xml文件生成View对象。为了提供用户体验我想把inflate(...)的调用,放到另一个线程去生成View,发现报android.view.InflateException: Binary XML file line #88
在xml文件中第88行中的控件不能生成了是不是inflate(int resource, ViewGroup root)这个方法对线程有什么特殊的要求?

解决方案 »

  1.   

    是不是inflate(int resource, ViewGroup root)这个方法对线程有什么特殊的要求?没什么要求!LayoutInflater 对象调用方法前,必须初始化上下文不知道楼主初始化没!!! 
      

  2.   

    调用layoutInflater = this.getLayoutInflater();来获得LayoutInflater的实例的,this是主Activity的引用,这样可以吗?
      

  3.   

    ....应该要LayoutInflater.from(content   c)来获取填出实例吧。。
      

  4.   


    layoutInflater lay=layoutInflater.from(this)//this是主Activity的引用View myView=lay.inflate(int resource, ViewGroup root)这样的...
      

  5.   

    文档上说可以,我试了下也没问题,在线程中调用也可以,你还是贴下你的xml吧
    use getLayoutInflater() or getSystemService(String) to retrieve a standard LayoutInflater instance that is already hooked up to the current context