I’ve coded some function in a separate java project, it works, and outputs the right result. But when I try to make this .java file in a android project I just got an error saying:
The method getTextContent() is undefined for the type Node
This is the error I get when I dragged the java file from the java project into the android project..
Here is a bit of the code:
for (int k = 1; k<listDist.getLength(); k++) {
NodeList childs = listDist.item(listDist.getLength() -1).getChildNodes();
if ((childs.item(k)!=null)&&childs.item(k).getNodeName().equals("text")) {
totalKM = (childs.item(k).getTextContent());
finalResult = totalKM.substring(0, totalKM.lastIndexOf("km"));
return finalResult;
}
}
The error occurs in the variable totalKM.
As I understand Android can construct new Objects based on pure java classes? or isn’t that right? What can I do do solve this problem?
My project structure look like this
Project1
src
com.distance
MainActivity
Services
Distances
The .java file is located in the Services package
Node.getTextContent() is only available in Android API level 8 and up. You might need to adjust your minimum API level.