這裏是我的代碼:的Android改變的ImageView的背景中的自定義對話框不工作
private void setWeatherDialogInfoAndIcons(){
WeatherGoogle weather = WeatherGoogle.getInstance("istanbul");
String iconsPath = Environment.getExternalStorageDirectory().getAbsolutePath()+"/arla/images/hava/";
String[] allData = weather.getCityData().split("<>");
currentImage = (ImageView) customDialog.findViewById(R.id.imageViewcurrentWeatherImage);
currentInfo = (TextView) customDialog.findViewById(R.id.textViewCurrentInfo) ;
currentInfo.setText(allData[0] +"\n"+allData[1]+"\n"+allData[2]+"\n"+allData[3]);
currentImage.setBackgroundResource(R.drawable.air);
currentImage.setBackgroundDrawable(UiHelper.getDrawableFromSdcard(iconsPath + weather.getIconName(0)));
int j = 4;
for (int i = 0; i < dayInfos.size() ; i++) {
dayInfos.get(i).setText(allData[j] +"\nMin : "+ allData[j+1] +"\nMaks: "+ allData[j+2]
+ "\n" + allData[j+3] );
j+=4;
}
}
我可以改變textviews的文本,但是當我想設置imageviev的背景(currentImage)它不工作,它顯示對話框,但沒有背景Imageview。
currentImage.setBackgroundDrawable(UiHelper.getDrawableFromSdcard(iconsPath + weather.getIconName(0)));
我相信,我的方法getDrawableFromSdcard的作品,因爲我曾經在別的地方在我的代碼最後,我選中的圖標爲png和路徑。那麼問題是什麼?
它不能幫助我,因爲我試圖從SD卡獲取繪製! – ctugyildiz 2012-07-12 12:06:25
我更新了我的答案。 – 2012-07-12 12:09:42
謝謝,它的工作原理! – ctugyildiz 2012-07-12 12:13:56