2013-11-03 36 views

回答

1

LayoutInflater在运行时不适用于任意xml。请参阅有关LayoutInflater.inflate的评论。

重要由于性能原因,查看通货膨胀在很大程度上依赖于被在编译的时候做的XML文件的预处理。因此,在运行时,通过普通的XML文件使用LayoutInflater和XmlPullParser是不可能的。

该平台在Resources.java中执行了一个downcast,它做出了这个假设。

// XXX note that for now we only work with compiled XML files. 
// To support generic XML files we will need to manually parse 
// out the attributes from the XML file (applying type information 
// contained in the resources and such). 
XmlBlock.Parser parser = (XmlBlock.Parser)set;