我在测试应用程序中使用fedor的延迟加载列表实现,通过单击该按钮即可清除缓存。如何获取列表视图中已加载图像的缓存大小并以编程方式清除缓存?
这是用于保存缓存图像的代码:
public ImageLoader(Context context){
//Make the background thead low priority. This way it will not affect the UI performance.
photoLoaderThread.setPriority(Thread.NORM_PRIORITY-1);
mAssetManager = context.getAssets();
//Find the dir to save cached images
if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED))
cacheDir = new File(android.os.Environment.getExternalStorageDirectory(),"LazyList");
else
cacheDir = context.getCacheDir();
if(!cacheDir.exists())
cacheDir.mkdirs();
}
Run Code Online (Sandbox Code Playgroud)
编辑:
因此,基本上我将这段代码添加到了clearCache()方法中,但是在滚动时仍然看不到图像再次开始加载。
public void clearCache() {
//clear memory cache
long size=0;
cache.clear();
//clear SD cache
File[] files = cacheDir.listFiles();
for (File f:files) {
size = size+f.length();
if(size >= 200)
f.delete();
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个关于来自Android设备的视频流的问题,也许有人会给我一些关于我的问题的有用建议/建议.所以这是交易:
我有一个来自Android设备的视频流项目.想法是将设备连接到服务器,第一个是流式传输实时视频并将其上传到服务器,第二个设备正在流式传输并观看来自第一个设备的视频.所以有这样的连接:
First Device ----live streaming----> Web Server ------live streaming---->Second Device,第二个设备连接到Web服务器.
任何建议/建议我怎么能这样做以及我应该使用什么?我会很高兴听到你的想法.
提前致谢!
我试图在Android应用程序中使用switch语句,我必须检查一个整数是否等于Enum的某些值.代码如下:
public enum RPCServerResponseCode{
E_INCORRECT_LOGIN(4001),
E_ACCOUNT_DISABLED(4002),
E_ACCOUNT_NOT_ACTIVE(4003);
private int value;
private RPCServerResponseCode(int i) {
this.value=i;
}
public static RPCServerResponseCode getByValue(int i) {
for(RPCServerResponseCode dt : RPCServerResponseCode.values()) {
if(dt.value == i) {
return dt;
}
}
throw new IllegalArgumentException("No datatype with " + i + " exists");
}
}
}
Run Code Online (Sandbox Code Playgroud)
我的switch语句如下所示:
int errorCode;
switch(errorCode){
case RPCServerResponseCode.E_INCORRECT_LOGIN :
{
if (user.isAuthenticated)
{
// logout before login
}
break;
}
case RPCServerResponseCode.E_ACCOUNT_NOT_ACTIVE:
{
if (user.isAuthenticated)
{
//logout
}
break;
}
}
}
Run Code Online (Sandbox Code Playgroud)
但我得到错误说:"类型不匹配:无法从RPCCommucatorDefines.RPCServerResponseCode转换为int".有任何建议如何解决这个问题?提前致谢!!!
嗨,我需要一些帮助,了解如何通过发送图像uri,intent.putExtra()所以我可以改变另一个活动的来源intent.getExtra().
所以基本上我正在尝试从Activity1 发送intent.putExtra("R.drawable.image"); 到Activity2并显示图像.
我试着这样做:
活动1:
intent.putExtra("image_url","R.drawable.image");
Run Code Online (Sandbox Code Playgroud)
活性2:
ImageView image = (ImageView) findViewById(R.id.image);
String image_link = getIntent().getStringExtra("image_url");
Run Code Online (Sandbox Code Playgroud)
我不知道如何将其设置为图像背景.有什么建议?
我对解析特定json字符串有疑问.在我的情况下,我找不到任何可以帮助我的东西.我有这个json:
{
"AM": {
"country_name": "Armenia",
"data": {
"180854": {
"time_published": "2012-03-30 13:31:39",
"title": "Example",
},
"180926": {
"time_published": "2012-04-02 05:21:44",
"title": "Example",
}, // keeps going on
}
},
"BM": {
"country_name": "Bolivia",
"data": {
"180854": {
"time_published": "2012-03-30 13:31:39",
"title": "Example",
},
"180926": {
"time_published": "2012-04-02 05:21:44",
"title": "Industrial PPI inflation eases to 5.5% y/y in February",
}
}
}, // continues
}
Run Code Online (Sandbox Code Playgroud)
所以,我想知道的是有一种方式来获得的该值JSONObject:AM,BM.它们每次都不同,所以我无法检查它们,但我希望能够将它们保存为String.以下是我实际用来解析JSON的内容:
public static void jsonParser(String …Run Code Online (Sandbox Code Playgroud)