我想從mysql獲取
數據的結果時在循環中有一個if else語句..但是if語句無法讀取結果..但代碼完美
我看到這個問題在我的情況下。無法從MYSQL讀取字符串結果
這裏是我的代碼從我的AsyncTask
for (int i = 0; i < markers.length(); i++) {
JSONObject c = markers.getJSONObject(i);
// Storing each json item in variable
Double LAT = c.getDouble(TAG_LAT);
Double LNG = c.getDouble(TAG_LNG);
String color = c.getString(TAG_STATUS);
String red = "ongoing";
String green = "firedout";
if (color == red){
LatLng position = new LatLng(LAT, LNG);
status.add(new MarkerOptions()
.title(color)
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED))
.position(position));
// adding HashList to ArrayList
}
if (color == green){
LatLng position = new LatLng(LAT, LNG);
status.add(new MarkerOptions()
.title(color)
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN))
.position(position));
// adding HashList to ArrayList
}
}
我覺得你如果要是(顏色==「綠色」) – Joseph 2015-01-21 04:40:09
我認爲,這樣一個條件小姐something.do一些像這樣的事情..當我刪除if語句..我的標題正在獲得狀態..和標記被添加到他們相應的標題的地圖 – 2015-01-21 04:42:10
沒有它不起作用..存儲在我的數據庫中的數據基本上是「正在進行」和「開除」只有..所以如果結果正在進行中,標記的顏色必須是紅色,如果結果被觸發,它必須是綠色的。 – 2015-01-21 04:54:21