我使用SAX解析器,当我添加@Override到该方法的startElement(字符串,字符串,字符串,属性)型的......必须覆盖或实现超方法
public void startElement(String namespaceURI, String localName, String qName,
Attributes atts) throws SAXException {
//Do somethink :)
}
我有错误:
The method startElement(String, String, String, Attributes) of type ... must override or implement a supertype method
UPDATE
底部I添加此文件的完整代码。如果你想anythink别人告诉我:)
import java.util.ArrayList;
import java.util.jar.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
import android.util.Log;
public class ParseGEOLocal extends DefaultHandler {
String tempLoc;
private static ArrayList<Locations> locations;
private Locations location;
public ParseGEOLocal() {
super();
locations = new ArrayList<Locations>();
}
public static ArrayList<Locations> getLocations() {
return locations;
}
@Override
public void startElement(String namespaceURI, String localName, String qName,
Attributes atts) throws SAXException {
if(qName.equalsIgnoreCase("Result")){
location = new Locations();
}
}
@Override
public void characters(char[] ch, int start, int length)
throws SAXException {
tempLoc = new String(ch, start, length);
}
@Override
public void endElement(String uri, String localName, String qName)
throws SAXException {
if(localName.equalsIgnoreCase("Result"))
locations.add(location);
else if(localName.equalsIgnoreCase("city"))
location.setCity(tempLoc);
else if(localName.equalsIgnoreCase("uzip"))
location.setUzip(tempLoc.replaceAll("[\\s\\-()]", ""));
else if(localName.equalsIgnoreCase("woeid"))
location.setWOEID(tempLoc);
}
}
显示类声明。你在扩展和实施什么? – DwB