I use these lines of code to extract and parse the xml layout.
Activity activity = MyClassName.this;
Resources res = activity.getResources();
XmlResourceParser xpp = res.getXml(R.layout.MyXmlName);
//...parse...
It can parse all tags and attributes from the xml, the problem is it can only extract the very first loaded version of the xml.
When I dynamically change attributes like myButton.setText("new_name")
, the parser always returns the earliest button name. Same thing, nothing else will change in the xml if anything is modified after loading.
When I dynamically set visibility, which is an attribute not existed in the original xml file, it only extracts the earliest xml without the new attribute. I hope it can be shown too.
Is my code or my approach wrong? Or is parsing dynamic xml impossible? If so, is there an alternative way to get the dynamic layout?