ImageView中的图像没有变化

时间:2015-06-19 05:51:17

标签: android universal-image-loader picasso

我在android中为imageLoading制作了一个演示,我先使用了U may prefer something like this,it can be used both in Ios and Android. var win = Titanium.UI.createWindow({ title : 'app', backgroundColor : 'white', fullscreen : false, navBarHidden : true, layout : 'vertical', height : Ti.UI.FILL, width : Ti.UI.FILL }); var checkboxview = Titanium.UI.createView({ width : Ti.UI.FILL, height : Ti.UI.SIZE, //layout : 'horizontal', horizontalWrap : false, //right : '10dp', //left : '10dp', layout : 'horizontal', //backgroundImage : '/images/backblue.png' backgroundColor : '#045FB4', //top : '20dp', //backgroundColor:'' }); win.add(checkboxview); var checkbox = Ti.UI.createButton({ title : '', top : 10, right : 10, width : 30, height : 30, borderColor : 'black', borderWidth : 2, borderRadius : 3, backgroundColor : 'white', backgroundImage : 'none', color : '#fff', font : { fontSize : 25, fontWeight : 'bold' }, value : false //value is a custom property in this casehere. }); checkboxview.add(checkbox); var hinttext = Ti.UI.createLabel({ color : 'black', font : { fontSize : '17dp', //fontWeight : 'bold', fontFamily : 'Rod' }, left : '10%', text : 'user1' }); checkboxview.add(hinttext); //Attach some simple on/off actions checkbox.on = function() { this.backgroundColor = '#007690'; this.title = '\u2713'; this.value = true; }; checkbox.off = function() { this.backgroundColor = '#aaa'; this.title = ''; this.value = false; }; checkbox.addEventListener('click', function(e) { if (false == e.source.value) { e.source.on(); alert(hinttext.text); } else { e.source.off(); } }); var checkboxview1 = Titanium.UI.createView({ width : Ti.UI.FILL, height : Ti.UI.SIZE, //layout : 'horizontal', horizontalWrap : false, //right : '10dp', //left : '10dp', layout : 'horizontal', //backgroundImage : '/images/backblue.png' backgroundColor : '#045FB4', //top : '20dp', //backgroundColor:'' }); win.add(checkboxview1); var checkbox1 = Ti.UI.createButton({ title : '', top : 10, right : 10, width : 30, height : 30, borderColor : '#666', borderWidth : 2, borderRadius : 3, backgroundColor : '#aaa', backgroundImage : 'none', color : '#fff', font : { fontSize : 25, fontWeight : 'bold' }, value : false, //value is a custom property in this casehere. }); checkboxview1.add(checkbox1); var hinttext1 = Ti.UI.createLabel({ color : 'black', font : { fontSize : '17dp', //fontWeight : 'bold', fontFamily : 'Rod' }, left : '10%', width : Ti.UI.SIZE, height : Ti.UI.SIZE, text : "User2" }); checkboxview1.add(hinttext1); //Attach some simple on/off actions checkbox1.on = function() { this.backgroundColor = '#007690'; this.title = '\u2713'; this.value = true; }; checkbox1.off = function() { this.backgroundColor = '#aaa'; this.title = ''; this.value = false; }; checkbox1.addEventListener('click', function(e) { if (false == e.source.value) { e.source.on(); alert(hinttext1.text); } else { e.source.off(); } }); 然后UniversalImageLoader然后再使用了picasso类,但有时我将新图像上传到服务器并且它成功上传到服务器,当我试图将其设置为ImageLoader时,之前加载的图像保持不变,它没有变化,我对此感到非常沮丧并浪费了2天时间来解决这个问题,没有运气,请帮助我挽救生命。

我的代码如下:

ImageView

2 个答案:

答案 0 :(得分:3)

尝试在网址末尾添加cachebreaker

String imageurl1 = Const.PREF_PROFILE_PIC + "?" + new Date().getTime();
String imageurl2 = Const.PREF_COVER_PIC + "?" + new Date().getTime();

Picasso.with(getApplicationContext())
        .load(Pref.getValue(getApplicationContext(),
                imageurl1, "")).into(iv_profile);

Picasso.with(getApplicationContext())
        .load(Pref.getValue(getApplicationContext(),
                imageurl2, "")).into(iv_cover);

这将在您创建图像时自动附加当前时间戳,它将使浏览器再次查看图像,而不是检索缓存中的图像。

答案 1 :(得分:0)

这个想法与上面相同。但它对我没用。

我从这个link

得到了答案

更改您的网址,如下所示:

String imageurl = url + "?time=" + System.currentTimeMillis();
Picasso.with(getContext()).load(imageurl).into(imageView);
这对我有用。感谢

相关问题