Note that there are some explanatory texts on larger screens.

plurals
  1. POOptions cannot be resolved to a variable
    primarykey
    data
    text
    <p>I get the error: "Options cannot be resolved to a variable" when I try to use <code>options[0][0]</code> </p> <p>I want to compare some values which <code>options[i][j]</code> contains to a value within <code>onLocationChanged</code></p> <p>Here's my code:</p> <pre><code>public static void main(String argv[]) { try { File fXmlFile = new File("/Users/mkyong/staff.xml"); DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); Document doc = dBuilder.parse(fXmlFile); //optional, but recommended //read this - http://stackoverflow.com/questions/13786607/normalization-in-dom-parsing-with-java-how-does-it-work doc.getDocumentElement().normalize(); NodeList nList = doc.getElementsByTagName("station"); int rows = nList.getLength(); int cols = 9; String[][]options = null; for (int temp = 0; temp &lt; nList.getLength(); temp++) { Node nNode = nList.item(temp); if (nNode.getNodeType() == Node.ELEMENT_NODE) { Element eElement = (Element) nNode; options = new String[cols][rows]; options[0][0] = eElement.getElementsByTagName("name").item(0).getTextContent(); options[1][0] = eElement.getElementsByTagName("code").item(0).getTextContent(); options[2][0] = eElement.getElementsByTagName("lat").item(0).getTextContent(); options[3][0] = eElement.getElementsByTagName("long").item(0).getTextContent(); options[4][0] = eElement.getElementsByTagName("longlat").item(0).getTextContent(); options[5][0] = eElement.getElementsByTagName("uziadvies").item(0).getTextContent(); options[6][0] = eElement.getElementsByTagName("bijzonderheden").item(0).getTextContent(); options[7][0] = eElement.getElementsByTagName("ref").item(0).getTextContent(); options[8][0] = eElement.getElementsByTagName("groterkleiner").item(0).getTextContent(); } } } catch (Exception e) { e.printStackTrace(); } } class mylocationlistener implements LocationListener { @Override public void onLocationChanged(Location location) { if(location != null) { double pLong = location.getLongitude(); double pLat = location.getLatitude(); gpsSpeed = ((location.getSpeed()*3600)/1000); textLat.setText(Double.toString(pLat)); textLong.setText("jo"); //If I enter here I get the error: //String test = options[0][0]; double compareLatCoords = 51.704704; double compareLongCoords = 4.854369; testid.setText(Float.toString(gpsSpeed)); if (pLat &lt;= compareLatCoords) { textChange.setText("Je bent net de bedaulxstraat doorgereden"); } if (pLong &gt;= compareLongCoords) { textChange.setText("U bent door een andere straat gereden dan daarnet."); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload