안녕하세요 저는 Android api에서 UniversalImageLoader
을 사용하고 있습니다. 현재 날씨 API에서 이미지를로드하지만 새로운 데이터를 가져올 때마다 이미지 로더가로드되지 않습니다. 새로운 이미지들.유니버설 이미지 로더는 초기 이미지 만로드합니다. 새 이미지가로드되지 않습니다.
이것은 api가 데이터를 반환 할 때 URL에서 이미지를로드하고 새 이미지를 가져올 때 이전 이미지가 있던 위치와 동일한 위치에 새 이미지가로드되는 방식입니다. 이미지 로더가 항상 내 앱에서 새 URL을로드하는지 확인하려면 어떻게해야합니까?
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.weather, container, false);
int i = getArguments().getInt(ARG_MENU_NUMBER);
String titleString = getResources().getStringArray(R.array.drawer_menu)[i];
getActivity().setTitle(titleString);
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
getActivity()).build();
ImageLoader.getInstance().init(config);
options = new DisplayImageOptions.Builder()
.displayer(new RoundedBitmapDisplayer(2)).build();
return view;
}
public void processJson(String json) {
w.setText("Wind Speed");
ws.setText("Wind Direction");
hu.setText("Humidity");
pr.setText("Pressure");
String weatherDescription = null;
String weatherUrl = null;
Calendar calender = Calendar.getInstance();
try {
JSONObject jObj = new JSONObject(json);
JSONObject jobject = jObj.getJSONObject("data");
JSONArray jarrayConditions = jobject.getJSONArray("current_condition");
for(int i = 0;i < jarrayConditions.length();i++){
JSONObject jobject2 = jarrayConditions.getJSONObject(i);
String tempc = jobject2.getString("temp_C");
String windSpeed = jobject2.getString("windspeedKmph");
String windDirections = jobject2.getString("winddirDegree");
String airHumidity = jobject2.getString("humidity");
String airPressure = jobject2.getString("pressure");
for(int j = 0; j < jobject2.getJSONArray("weatherDesc").length();j++){
weatherDescription = jobject2.getJSONArray("weatherDesc").getJSONObject(j).getString("value");
}
wind.setText(windSpeed+ " m/s");
windDirection.setText(windDirections+ "\u00B0");
humidity.setText(airHumidity+ " %");
pressure.setText(airPressure+ " hPa");
weather.setText(weatherDescription);
temp.setText(new DecimalFormat("#").format(jarrayConditions.getJSONObject(i).getDouble("temp_C"))
+ "\u2103");
}
JSONArray jarrayWeather = jobject.getJSONArray("weather");
for(int i = 0;i < jarrayWeather.length();i++){
JSONObject jobject3 = jarrayWeather.getJSONObject(i);
String daysTempsH = jobject3.getString("tempMaxC");
String daysTempsL = jobject3.getString("tempMinC");
String date = jobject3.getString("date");
for(int j = 0; j < jobject3.getJSONArray("weatherIconUrl").length();j++){
weatherUrl = jobject3.getJSONArray("weatherIconUrl").getJSONObject(j).getString("value");
}
mArrayHigh.add(daysTempsH);
mArrayLow.add(daysTempsL);
mArrayImage.add(weatherUrl);
mArrayDate.add(date);
}
min.setText("L "+mArrayLow.get(0)+ "\u2103");
max.setText("H "+mArrayHigh.get(0)+ "\u2103");
tvDay1L.setText("L "+mArrayLow.get(1)+ "\u2103");
tvDay1H.setText("H "+mArrayHigh.get(1)+ "\u2103");
calender.setTime(new SimpleDateFormat("yyyy-MM-dd").parse(mArrayDate.get(1)));
tvDay1.setText(getDayOfWeek(calender.get(Calendar.DAY_OF_WEEK)));
String imageUrl1 = mArrayImage.get(1);
ImageLoader.getInstance()
.displayImage(imageUrl1, day1Icon, options);
tvDay2L.setText("L "+mArrayLow.get(2)+ "\u2103");
tvDay2H.setText("H "+mArrayHigh.get(2)+ "\u2103");
calender.setTime(new SimpleDateFormat("yyyy-MM-dd").parse(mArrayDate.get(2)));
tvDay2.setText(getDayOfWeek(calender.get(Calendar.DAY_OF_WEEK)));
String imageUrl2 = mArrayImage.get(2);
ImageLoader.getInstance()
.displayImage(imageUrl2, day2Icon, options);
tvDay3L.setText("L "+mArrayLow.get(3)+ "\u2103");
tvDay3H.setText("H "+mArrayHigh.get(3)+ "\u2103");
calender.setTime(new SimpleDateFormat("yyyy-MM-dd").parse(mArrayDate.get(3)));
tvDay3.setText(getDayOfWeek(calender.get(Calendar.DAY_OF_WEEK)));
String imageUrl3 = mArrayImage.get(2);
ImageLoader.getInstance()
.displayImage(imageUrl3, day3Icon, options);
tvDay4L.setText("L "+mArrayLow.get(4));
tvDay4H.setText("H "+mArrayHigh.get(4));
calender.setTime(new SimpleDateFormat("yyyy-MM-dd").parse(mArrayDate.get(4)));
tvDay4.setText(getDayOfWeek(calender.get(Calendar.DAY_OF_WEEK)));
String imageUrl4 = mArrayImage.get(4);
ImageLoader.getInstance()
.displayImage(imageUrl4, day4Icon, options);
}catch(Exception e){
e.printStackTrace();
}
}
감사하지만 – user1534409
worke의 일을하지 않았다 나를 위해 d :) – NarendraJi