ImageLoader的缓存+PopupWindow的一些使用
来源:互联网 发布:北京pk10网络关注平台 编辑:程序博客网 时间:2024/06/16 14:38
package demo01.com.bawei.xlistview.refresh;
import android.app.Application;
import android.os.Environment;
import com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache;
import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import java.io.File;
public class MyApplication extends Application{
@Override
public void onCreate() {
}
/**
* 配置图片是否缓存
*/
public static DisplayImageOptions getDisplayImageOption(){
DisplayImageOptions options = new DisplayImageOptions.Builder()
.showImageForEmptyUri(R.mipmap.ic_empty)
.showImageOnFail(R.mipmap.ic_error)
.cacheInMemory(true)
.cacheOnDisk(true)
.build();
return options;
}
import android.app.Application;
import android.os.Environment;
import com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache;
import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import java.io.File;
public class MyApplication extends Application{
@Override
public void onCreate() {
String path = Environment.getExternalStorageDirectory()+"/123";File cacheDir = new File(path);//没有网的情况,首先回去内存找图片, 如果内存不存在次张图片的话,去sdcard,->去网络加载ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this) //配置线程的优先级,图片加载为首 .threadPriority(100) //指定由多个线程去加载图片 .threadPoolSize(5) //指定要缓存多大尺寸的图片(内存缓存) .memoryCacheExtraOptions(200,200) //配置sdcard缓存路径 .diskCache(new UnlimitedDiskCache(cacheDir)) //指定图片的名字,根据MD5算出来的一个串号(串号不会重名) .diskCacheFileNameGenerator(new Md5FileNameGenerator()) //指明图片在内存占用多大空间(APP默认空间1/8) .memoryCacheSize(2 * 1024 * 1024) //指定图片在sdcard缓存多大(指的是占用空间) .diskCacheSize(50 * 1024 * 1024) .build();ImageLoader.getInstance().init(config);
}
/**
* 配置图片是否缓存
*/
public static DisplayImageOptions getDisplayImageOption(){
DisplayImageOptions options = new DisplayImageOptions.Builder()
.showImageForEmptyUri(R.mipmap.ic_empty)
.showImageOnFail(R.mipmap.ic_error)
.showImageOnLoading(R.mipmap.loading)
//这是设置圆形头像.displayer(new CircleBitmapDisplayer())
.cacheInMemory(true)
.cacheOnDisk(true)
.build();
return options;
}
}
//Window
package demo01.com.bawei.popwindow;import android.graphics.drawable.ColorDrawable;import android.os.Bundle;import android.support.v7.app.AppCompatActivity;import android.view.View;import android.widget.PopupWindow;import android.widget.TextView;public class MainActivity extends AppCompatActivity { private TextView mMenuTv; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mMenuTv = (TextView) findViewById(R.id.menu); mMenuTv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showPopWindow(); } }); } private void showPopWindow(){ View view = View.inflate(this, R.layout.item, null); PopupWindow window = new PopupWindow(view,100,100); //下面这代码就是点击外面可以退出pop 两个缺一不可 window.setBackgroundDrawable(new ColorDrawable()); window.setOutsideTouchable(true); TextView tv1 = (TextView) view.findViewById(R.id.pop_computer); TextView tv2 = (TextView) view.findViewById(R.id.pop_financial); TextView tv3 = (TextView) view.findViewById(R.id.pop_manage); window.showAsDropDown(mMenuTv); }}//popupwindow的布局
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:orientation="vertical" android:gravity="center_horizontal" android:background="#ff00" android:layout_height="match_parent"> <TextView android:id="@+id/pop_computer" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="计算机"/> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="#000000" /> <TextView android:id="@+id/pop_financial" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="金融"/> <View android:layout_width="match_parent" android:background="#000000" android:layout_height="1dp" /> <TextView android:id="@+id/pop_manage" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="管理"/> <View android:layout_width="match_parent" android:background="#000000" android:layout_height="1dp"/></LinearLayout>//activity中布局
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:orientation="vertical" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="demo01.com.bawei.popwindow.MainActivity"> <TextView android:id="@+id/menu" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#50484b" android:padding="10dp" android:text="菜单"/></LinearLayout>
阅读全文
0 0
- ImageLoader的缓存+PopupWindow的一些使用
- 图片缓存ImageLoader的使用
- ImageLoader使用的DiskLruCache硬盘缓存算法
- PopupWindow的一些使用总结
- ImageLoader 的一些配置
- 设置ImageLoader的图片缓存
- ImageLoader的SD卡缓存
- 最简单的ImageLoader缓存
- 关于使用PopupWindow的一些问题
- 图片缓存库Picasso和ImageLoader的使用
- popupwindow的一些心得
- PopupWindow的一些属性
- 关于imageloader的一些理解
- 关于imageloader的一些见解
- ImageLoader的使用
- ImageLoader的使用
- 开源库ImageLoader的使用
- ImageLoader的基本使用
- 2年Java开发工作经验面试总结
- 初识Nginx
- 搭建FastDFS,Nginx,fastdfs-nginx-module图片资源服务器
- 实验二 链表的基本操作
- 搬走了
- ImageLoader的缓存+PopupWindow的一些使用
- ShoppingCart
- C++风格_Lambda表达式
- 打印出所有的“水仙花数”,所谓“水仙花数”是指一个三位数,其各位数字立方和等于该数本身。 例如:153是一个“水仙花数”,因为153=1的三次方+5的三次方+3的三次方
- mapreduceword count实例
- hdu1195Open the Lock
- Java垃圾回收机制与典型的垃圾回收算法
- 1120. Friend Numbers (20)
- 剑指offer--删除链表中重复的结点