问题
Hi I have one xml file successfully parsed my before. now i am change simple modification in my xml file after i am getting lot of error. how to solve this error i don't know i post my my xml file 1st and am using sax parser.
i have two spinner if i click 1st spinner its shows test1, test2, test3 then i select test1 its shows test1 sub tag name stest1 to stest5. if select test2 my 2nd spinner show stest6 to stest10 this is my working xml file output now i am trying to add one tag in sltag from my xml file already my sltag display name tag now i am add here my problem is started. my problem is how to get both values into my sltag i need separate string value so i passed class in my sltag array list and create class also after declare name and path into array list then how to get both string value My purpose is when i select 2nd spinner value that i want to show some images in same screen bottom i trying to get path string value.
This is my error: 1. error line: Type mismatch: cannot convert from ArrayList to ArrayList
line
source link: http://paste.org/42566
other java files link here:
http://paste.org/42567
http://paste.org/42568
http://paste.org/42569
回答1:
Your method getSLTag
is declared to return an ArrayList<String>
but the variable sltag
in the xmlTag
class is actually an ArrayList<SubChild>
hence the type mismatch.
So to answer your additional comment about wanting to get path string from sltag, you will need to iterate over the collection of SubChild
s and add each path to a new List of Strings, e.g.
public ArrayList<String> getSLTag(String hltag) {
List<String> slTags = new ArrayList<String>();
for(int i = 0; i < xmlTagInfo.size(); i++) {
if( xmlTagInfo.get(i).hltag == hltag ) {
for (SubChild child : xmlTagInfo.get(i).sltag) {
// Your SubChild class actually declares path and name to be an ArrayList of Strings, but surely they should just be Strings?
slTags.add(child.getPath());
}
}
}
return slTags;
}
来源:https://stackoverflow.com/questions/8574402/error-type-mismatch-cannot-convert-from-arraylistsubchild-to-arrayliststrin