1

Simple code for parsing activity_main.xml

XmlResourceParser xmlResourceParser = res.getXml(R.layout.activity_main);

Android Studio finds error "Expected resource of type xml", but runs this code and app works correct. enter image description here

tehnolog
  • 1,204
  • 1
  • 11
  • 23

2 Answers2

0

Android Studio uses an inspector to help you find an error, it expects a resource type 'R.xml.nameresource', obviously works because steps still an xml. For delete error you can disable inspection 'Constant and Resource Type Mismatches' options or add a xml folder in your res folder, create a new xml file and copy your content

0

The resource type of that resource is technically not xml, instead it is actually layout. I think it must still be working because layout files are also XML files.

JasonWyatt
  • 5,275
  • 1
  • 31
  • 39