I am writing an Android application for work that shows the status of our phone lines, but it is neither here nor there.
I call one of our servers and get the JSON status text. Then I parse this by putting each row in a SortedMap (TreeMap), with the key being the name of the row and my own class as a value (which contains status and other data).
All of this works great.
When the application starts, it should show every line and information that I received, but nothing is updated.
JSON is returned and correctly added to the map.
This is a snapshot of code that does not work. I just iterate over the map and, depending on the key value, updates the corresponding TextView. The problem I am facing is that when it gets into the IF statement that matches it, it never runs this code. He skips it as if the values do not match.
I do not see errors. This is the only way to do this, as I know that you cannot use Switch..Case, etc.
Can anyone see my mistake? I have been coding on Android for 1 week, so its probably a beginner's mistake!
Thanks neil
Iterator iterator = mapLines.entrySet().iterator();
while(iterator.hasNext())
{
Map.Entry<String, Status> mapEntry = (Map.Entry<String, Status>)iterator.next();
String key = (String)mapEntry.getKey();
Status value = (Status)mapEntry.getValue();
if(key == "Ski")
{
TextView tvStatus = (TextView)findViewById(R.id.SkiStatus);
tvStatus.setText(value.Status);
}
else if(key == "Cruise")
{
TextView tvStatus = (TextView)findViewById(R.id.CruiseStatus);
tvStatus.setText(value.Status);
}
else if(key == "Villas")
{
TextView tvStatus = (TextView)findViewById(R.id.VillasStatus);
tvStatus.setText(value.Status);
}
}
source
share