android.view.InflateException异常
如题:我在主线程(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)这个方法对线程有什么特殊的要求?
--------------------编程问答-------------------- 是不是inflate(int resource, ViewGroup root)这个方法对线程有什么特殊的要求?
没什么要求!LayoutInflater 对象调用方法前,必须初始化上下文
不知道楼主初始化没!!! --------------------编程问答--------------------
调用layoutInflater = this.getLayoutInflater();来获得LayoutInflater的实例的,this是主Activity的引用,这样可以吗? --------------------编程问答-------------------- ....应该要LayoutInflater.from(content c)来获取填出实例吧。。 --------------------编程问答--------------------
layoutInflater lay=layoutInflater.from(this)//this是主Activity的引用
View myView=lay.inflate(int resource, ViewGroup root)
这样的... --------------------编程问答--------------------
文档上说可以,我试了下也没问题,在线程中调用也可以,你还是贴下你的xml吧
use getLayoutInflater() or getSystemService(String) to retrieve a standard LayoutInflater instance that is already hooked up to the current context --------------------编程问答-------------------- 学习了!
补充:移动开发 , Android