내 질문에 대한 대답은 아마도 거기에 있지만 개념을 올바르게 이해하고 있는지 확신 할 수 없습니다. if 문처럼 Gson 비동기 결과
는 난 단지{"meteo": "1"}
내가 성공적으로 GSON 그것을 읽고 내 축배를 표시 할 수 있습니다 포함하는 작은 JSON 파일을했습니다. A는이처럼 기반으로 "if 문"할 경우
그러나
: 나는 축배를했을에도 불구하고 그것은 항상 if 문의 두 번째 부분으로 이동if(meteoStatus == "1"){ // I know for sure it's 1
// Do something
} else {
// Do something else
}
을 바로 직전 나에게 일을 보여 여기
코드의 전체 섹션 : 어떤 도움이 높게 평가 될 것이다StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
String url = "http://www.boisdelacambre.be/ios/json/weather.php?key=53666d6c7b206a532d52403e414d2579";
String result = getUrlContents(url);
gsonInstance = new Gson();
meteo = new Meteo();
meteo = gsonInstance.fromJson(result, meteo.getClass());
String meteoStatus = meteo.getMeteo();
View rootView = inflater.inflate(R.layout.fragment_meteo, container, false);
ImageWeather = (ImageView) rootView.findViewById(R.id.imageWeather);
DonnesOuRemis = (TextView) rootView.findViewById(R.id.donnesOuRemis);
Toast.makeText(getActivity(), meteoStatus, Toast.LENGTH_LONG).show();
if(meteoStatus == "1"){
// il fait beau
Toast.makeText(getActivity(), "Pas remis !!", Toast.LENGTH_LONG).show();
ImageWeather.setImageResource(R.drawable.soleil);
DonnesOuRemis.setText("Donnés");
DonnesOuRemis.setTextColor(Color.parseColor("#06f828"));
} else {
Toast.makeText(getActivity(), "Pourquoi remis ??", Toast.LENGTH_LONG).show();
ImageWeather.setImageResource(R.drawable.pluie);
DonnesOuRemis.setText("Remis");
DonnesOuRemis.setTextColor(Color.parseColor("#f80b27"));
}
;-)
경우 meteoStatus.equals ("1")'시도' –
작품! 감사합니다. (이유를 모르겠다해도 ...) –
[Java에서 문자열을 어떻게 비교합니까?] (http://stackoverflow.com/questions/513832/how-do-i-compare- strings-in-java) – Selvin