Viewpager图片自动轮播,网络图片加载,图片自动刷新
package com.teffy.viewpager; import java.util.ArrayList;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout; public class MainActivity extends Activity {
private ViewPager mViewPager;
private ViewPagerAdapter adapter;
String[] urls = new String[] {
"http://img4.imgtn.bdimg.com/it/u=3741386655,1614062939&fm=21&gp=0.jpg",
"http://img1.imgtn.bdimg.com/it/u=112648096,582309873&fm=23&gp=0.jpg",
"http://photocdn.sohu.com/20120213/Img334596783.jpg",
"http://pic11.nipic.com/20101210/2531170_111449179301_2.jpg",
"http://www.foto8.net/files/201004/27/d272194910.jpg",
"http://www.sootuu.com/photo/UploadFile/2006-4/20064304138937.jpg",
"http://www.itxtbook.com/attachment/Day_081022/23_163307_e9b4513a7afee66.jpg",
"http://img7.mypsd.com.cn/20120821/Mypsd_13920_201208211752500005B.jpg"
};
private ArrayList<View> dots = new ArrayList<View>();
private int oldPosition = 0;//记录上一次点的位置
private int currentItem; //当前页面
private ScheduledExecutorService scheduledExecutorService;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); mViewPager = (ViewPager) findViewById(R.id.vp_guanggao);
mViewPager.setOnPageChangeListener(new OnPageChangeListener() {
@Override
public void onPageSelected(int position) {
dots.get(oldPosition).setBackgroundResource(R.drawable.dxt_point_nomral);
dots.get(position).setBackgroundResource(R.drawable.dxt_point_selected);
oldPosition = position;
currentItem = position;
} @Override
public void onPageScrolled(int arg0, float arg1, int arg2) {
} @Override
public void onPageScrollStateChanged(int arg0) {
}
});
initDots();
adapter = new ViewPagerAdapter(this,urls);
mViewPager.setAdapter(adapter);
vpChangeTask();
} private void initDots() {
LinearLayout ll_vp_point = (LinearLayout) findViewById(R.id.ll_vp_point);
for (int i = 0; i <urls.length; i++) {
ImageView iv_image = (ImageView) getLayoutInflater().inflate(R.layout.item_dots, null);
if(i ==0){
iv_image.setBackgroundResource(R.drawable.dxt_point_selected);
}
iv_image.setTag(urls[i]);
ll_vp_point.addView(iv_image);
dots.add(iv_image);
}
} private void vpChangeTask() {
scheduledExecutorService = Executors.newSingleThreadScheduledExecutor();
scheduledExecutorService.scheduleWithFixedDelay(new ViewPagerTask(), 2,3, TimeUnit.SECONDS);
}
// 切换图片
private class ViewPagerTask implements Runnable {
@Override
public void run() {
currentItem = (currentItem + 1) %urls.length;
mHandler.obtainMessage().sendToTarget();
}
}
@SuppressLint("HandlerLeak")
private Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
mViewPager.setCurrentItem(currentItem);
}
};
}
package com.teffy.viewpager; import com.teffy.viewpager.AsyncImageLoader.ImageCallBack; import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar; public class ViewPagerAdapter extends PagerAdapter {
Context context; String[] urls;
LayoutInflater layoutInflater ;
AsyncImageLoader asyncImageLoader;
public ViewPagerAdapter(Context context,String[] urls) {
this.context=context;
this.urls=urls;
layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
asyncImageLoader=new AsyncImageLoader();
} @Override
public void destroyItem(View container, int position, Object object) {
((ViewPager) container).removeView((View) object);
} @Override
public int getCount() {
return urls.length;
} @Override
public boolean isViewFromObject(View view, Object object) {
return view.equals(object);
} @Override
public Object instantiateItem(final View view, int position) {
final String imgUrl = urls[position];
final View imageLayout = layoutInflater.inflate(R.layout.item_pager_image, null);
final ImageView imageView = (ImageView) imageLayout.findViewById(R.id.image);
final ProgressBar progressBar = (ProgressBar) imageLayout.findViewById(R.id.loading);
imageView.setTag(imgUrl);
// 如果联网
if (UtilTool.checkConnection(context)) {
Bitmap bmpFromSD = FileCache.getInstance().getBmp(imgUrl);
if (null != bmpFromSD) {
imageView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, bmpFromSD.getHeight()));
imageView.setImageBitmap(bmpFromSD);
progressBar.setVisibility(View.INVISIBLE);
} else {
Drawable cachedImage = asyncImageLoader.loaDrawable(imgUrl,new ImageCallBack() {
@SuppressWarnings("unused")
@Override
public void imageLoaded(Drawable imageDrawable) {
Bitmap bitmap = UtilTool.drawToBmp(imageDrawable);
FileCache.getInstance().savaBmpData(imgUrl, bitmap);// 先缓存起来
// FileCache.getInstance().savaBmpData(view.getTag().toString(), bitmap);// 先缓存起来
ImageView imageViewByTag = null;
if (null != bitmap) {
imageViewByTag = (ImageView) imageView.findViewWithTag(imgUrl);
imageViewByTag.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,bitmap.getHeight()));
}
if (imageViewByTag != null) {
if (true) {
imageViewByTag.setImageBitmap(bitmap);
progressBar.setVisibility(View.INVISIBLE);
} else {
if (bitmap != null) {
imageViewByTag.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,LinearLayout.LayoutParams.WRAP_CONTENT));
imageViewByTag.setImageBitmap(bitmap);
imageViewByTag.setScaleType(ImageView.ScaleType.MATRIX);
progressBar.setVisibility(View.INVISIBLE);
}
}
}
}
});
if (cachedImage == null) {
imageView.setImageResource(R.drawable.ic_launcher);
} else {
if (UtilTool.isWifi(context)) {
Bitmap bitmap = UtilTool.drawToBmp(cachedImage);
imageView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,bitmap.getHeight()));
imageView.setImageBitmap(bitmap);
} else {
imageView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,LinearLayout.LayoutParams.WRAP_CONTENT));
Bitmap bitmap = UtilTool.drawToBmp(cachedImage);
imageView.setImageBitmap(bitmap);
progressBar.setVisibility(View.INVISIBLE);
}
}
}
} else {
Bitmap bmpFromSD = FileCache.getInstance().getBmp(imgUrl);
if (null != bmpFromSD) {
ImageView imageViewByTag = (ImageView) imageView.findViewWithTag(imgUrl);
imageViewByTag.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,bmpFromSD.getHeight()));
imageViewByTag.setImageBitmap(bmpFromSD);
} else {
imageView.setImageResource(R.drawable.ic_launcher);
progressBar.setVisibility(View.GONE);
}
}
((ViewPager) view).addView(imageLayout, 0);
return imageLayout;
}
}
package com.teffy.viewpager; import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.ConnectivityManager;
import android.net.NetworkInfo; public class UtilTool {
/**
* Drawable转换成Bitmap
* @param d
* @return
*/
public static Bitmap drawToBmp(Drawable d) {
if (null != d) {
BitmapDrawable bd = (BitmapDrawable) d;
return bd.getBitmap();
}
return null;
} /**
* 检测网络连接
*
* @return
*/
public static boolean checkConnection(Context context) {
@SuppressWarnings("static-access")
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
if (networkInfo != null) {
return networkInfo.isAvailable();
}
return false;
} /**
* Wifi是否可用
* @param mContext
* @return
*/
public static boolean isWifi(Context mContext) {
ConnectivityManager connectivityManager = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo();
if (activeNetInfo != null && activeNetInfo.getTypeName().equals("WIFI")) {
return true;
}
return false;
}
}
package com.teffy.viewpager; import java.io.InputStream;
import java.lang.ref.SoftReference;
import java.net.URL;
import java.util.HashMap;
import java.util.Map; import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.Message; public class AsyncImageLoader { public Map<String, SoftReference<Drawable>> imageCache; public AsyncImageLoader() {
imageCache = new HashMap<String, SoftReference<Drawable>>();
} public Drawable loaDrawable(final String imageUrl, final ImageCallBack imageCallBack) {
Bitmap bmpFromSD = FileCache.getInstance().getBmp(imageUrl);
if (null != bmpFromSD) {
return new BitmapDrawable(bmpFromSD);
}
if (imageCache.containsKey(imageUrl)) {
SoftReference<Drawable> softReference = imageCache.get(imageUrl);
Drawable drawable = softReference.get();
if (null != drawable) {
return drawable;
}
} final Handler handler = new Handler() {
@Override
public void handleMessage(Message message) {
imageCallBack.imageLoaded((Drawable) message.obj);
}
}; new Thread() {
@Override
public void run() {
Drawable drawable = loadImageFromUrl(imageUrl);
imageCache.put(imageUrl, new SoftReference<Drawable>(drawable));
Message message = handler.obtainMessage(0, drawable);
handler.sendMessage(message);
}
}.start();
return null;
}
/**
* 下载图片
* @param url
* @return
*/
public Drawable loadImageFromUrl(String url) {
URL tempUrl;
InputStream inputStream = null;
Drawable drawable = null; try {
tempUrl = new URL(url); inputStream = (InputStream) tempUrl.getContent(); // BitmapFactory.Options o = new BitmapFactory.Options();
// o.inJustDecodeBounds =true;
// BitmapFactory.decodeStream(inputStream); } catch (Exception e) {
e.printStackTrace();
}
try {
drawable = Drawable.createFromStream(inputStream, "src");
} catch (OutOfMemoryError err) {
System.out.println("内存溢出...");
} return drawable;
} public interface ImageCallBack {
public void imageLoaded(Drawable imageDrawable);
} }
package com.teffy.viewpager; import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.Reader; import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.BitmapFactory;
import android.os.Environment;
import android.util.Log; public class FileCache { private static FileCache fileCache; // 本类的引用
private String strImgPath; // 图片保存的路径
private String strJsonPath;// Json保存的路径 private FileCache() {
String strPathHead = null;
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
strPathHead = Environment.getExternalStorageDirectory().toString();
} else{
strPathHead = "/data/data/com.teffy.viewpager";
}
strImgPath = strPathHead + "/vp/images/";
strJsonPath = strPathHead + "/vp/json/";
} public static FileCache getInstance() {
if (null == fileCache) {
fileCache = new FileCache();
}
return fileCache;
} public boolean saveData(String strApiUrl, String dataJson,String imgurl, Bitmap bmp) {
String fileName = this.toHexString(strApiUrl);
String imgName = imgurl.substring(
imgurl.lastIndexOf('/') + 2,
imgurl.length());
File jsonFile = new File(strJsonPath);
File imgFile = new File(strImgPath);
if (!jsonFile.exists()) {
jsonFile.mkdirs();
}
if (!imgFile.exists()) {
imgFile.mkdirs();
}
File fTXT = new File(strJsonPath + fileName + ".txt");
File fImg = new File(strImgPath + imgName);
this.writeToFile(dataJson, fTXT);
this.writeToFile(bmp, fImg);
return true;
} /**
* 保存json数据
* */
public boolean savaJsonData(String strApiUrl, String dataJson) {
String fileName = this.toHexString(strApiUrl);
File jsonFile = new File(strJsonPath);
if (!jsonFile.exists()) {
jsonFile.mkdirs();
}
File fTXT = new File(strJsonPath + fileName + ".txt");
if (fTXT.exists()) {
fTXT.delete();
}
this.writeToFile(dataJson, fTXT);
return true;
} // 用图片的URL来命名图片,并保存图片
public boolean savaBmpData(String imgurl, Bitmap bmp) {
String imgName = imgurl.substring(
imgurl.lastIndexOf('/') + 2,
imgurl.length());
File imgFileDirs = new File(strImgPath);
if (!imgFileDirs.exists()) {
imgFileDirs.mkdirs();
}
File fImg = new File(strImgPath + imgName);
if (fImg.exists()) {
fImg.delete();
}
this.writeToFile(bmp, fImg);
return true;
} // 自己给图片命名并保存图片
public boolean saveBmpDataByName(String bmpName, Bitmap bmp) {
File imgFileDirs = new File(strImgPath);
if (!imgFileDirs.exists()) {
imgFileDirs.mkdirs();
}
File fImg = new File(strImgPath + bmpName);
if (fImg.exists()) {
fImg.delete();
}
this.writeToFile(bmp, fImg);
return true;
} /**
*
* 参数fileName需与 fileName和saveData()方法中的fileName参数一致时,才能读出与保存时一致的数据
*
* */
public String getJson(String strApiUrl) {
String fileName = this.toHexString(strApiUrl);
File file = new File(strJsonPath + fileName + ".txt");
StringBuffer sb = new StringBuffer();
if (file.exists()) {
Reader reader = null;
try {
reader = new java.io.FileReader(file);
BufferedReader br = new BufferedReader(reader);
String str;
while (null != (str = br.readLine())) {
sb.append(str);
}
return sb.toString();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
return null;
} /**
* 传入图片的URL地址,来获得Bitmap
* */
public Bitmap getBmp(String imgurl) { String imgName = imgurl.substring(
imgurl.lastIndexOf('/') + 2,
imgurl.length()); File imgFile = new File(strImgPath + imgName);
if (imgFile.exists()) {
FileInputStream fis;
try {
fis = new FileInputStream(imgFile);
return BitmapFactory.decodeStream(fis);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else
Log.v("提醒", "要请求的图片文件不存在");
return null;
} // 通过图片名字来获得图片
public Bitmap getBmpByName(String bmpName) {
File imgFile = new File(strImgPath + bmpName);
if (imgFile.exists()) {
FileInputStream fis;
try {
fis = new FileInputStream(imgFile);
return BitmapFactory.decodeStream(fis);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else {
Log.v("提醒", "要请求的图片文件不存在");
}
return null;
} /**
* 传入图片的URL来获得图片文件
* */
public File getImgFile(String imgurl) {
String imgName = imgurl.substring(
imgurl.lastIndexOf('/') + 2,
imgurl.length());
File imgFile = new File(strImgPath + imgName);
return imgFile;
} private boolean writeToFile(String strData, File file) {
if (file.exists()) {
file.delete();
}
FileOutputStream fos = null;
try {
fos = new FileOutputStream(file);
BufferedOutputStream bos = new BufferedOutputStream(fos);
bos.write(strData.getBytes());
bos.flush();
bos.close();
return true;
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (null != fos) {
try {
fos.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
return false;
} private boolean writeToFile(Bitmap bmp, File file) {
if (file.exists()) {
file.delete();
}
String name = file.getName();
String geShi = name.substring(name.lastIndexOf('.'), name.length()); FileOutputStream fos = null;
try {
fos = new FileOutputStream(file);
BufferedOutputStream bos = new BufferedOutputStream(fos);
if (null != bmp) {
if (".JPEG".equalsIgnoreCase(geShi)
|| ".JPG".equalsIgnoreCase(geShi)) {
bmp.compress(CompressFormat.JPEG, 100, bos);
bos.flush();
bos.close();
} else if (".PNG".equalsIgnoreCase(geShi)) {
bmp.compress(CompressFormat.PNG, 100, bos);
bos.flush();
bos.close();
}
return true;
} else
bos.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (null != fos) {
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
Log.v("错误", "图片写入缓存文件错误");
}
}
}
return false;
} public boolean clearImgByImgUrl(String imgurl) {
File imgFile = this.getImgFile(imgurl);
if (imgFile.exists()) {
imgFile.delete();
return true;
}
return false;
} /**
* 删除SD卡上的全部缓存
* */
public int clearAllData() {
File imgDir = new File(strImgPath);
File txtDir = new File(strJsonPath);
File[] imgFiles = imgDir.listFiles();
File[] txtFiles = txtDir.listFiles();
int m = imgFiles.length;
int x = txtFiles.length; int g = 0;
int t = 0;
for (int i = 0; i < m; i++) {
if (imgFiles[i].exists()) {
if (imgFiles[i].delete())
g++;
} else
g++; }
for (int i = 0; i < x; i++) {
if (txtFiles[i].exists()) {
if (txtFiles[i].delete()) {
t++;
}
} else
t++;
}
if (g == m && t == x) {
return 1;
}
return 0;
}
private String toHexString(String s) {
String str = "";
for (int i = 0; i < s.length(); i++) {
int ch = (int) s.charAt(i);
String s4 = Integer.toHexString(ch);
str = str + s4;
}
return "0x" + str;// 0x表示十六进制
} // 转换十六进制编码为字符串
private String toStringHex(String s) {
if ("0x".equals(s.substring(0, 2))) {
s = s.substring(2);
}
byte[] baKeyword = new byte[s.length() / 2];
for (int i = 0; i < baKeyword.length; i++) {
try {
baKeyword[i] = (byte) (0xff & Integer.parseInt(
s.substring(i * 2, i * 2 + 2), 16));
} catch (Exception e) {
e.printStackTrace();
}
}
try {
s = new String(baKeyword, "utf-8");// UTF-16le:Not
} catch (Exception e1) {
e1.printStackTrace();
}
return s;
}
}
源码下载 :链接: http://pan.baidu.com/s/1i3sradv
Viewpager图片自动轮播,网络图片加载,图片自动刷新的更多相关文章
- selenium网页没加载完成就停止加载并自动刷新
判断一个网页10秒没加载完成就停止加载并自动刷新 driver=webdriver.Chome() driver.set_page_load_timeout(10) while True: try: ...
- 图片_ _优化Bitmap加载图片1
=========== 1 视图显示大量图片时的内存问题 setBackgroundResource 回去res 资源文件里面找适配手机当前屏幕的文件,所以消耗高,etBackgroundDra ...
- (Android图片内存优化)Picasso加载图片 教程。。详细版
Picasso 是 Android 上一个强大的图片下载和缓存库. 示例代码: ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 Picasso.with( ...
- easyUI datagrid 刷新取消加载信息 自动刷新闪屏问题
<style type="text/css"> /*-- 消除grid屏闪问题 --//*/ .datagrid-mask { opacity: 0; filter: ...
- 又优化了一下 Android ListView 异步加载图片
写这篇文章并不是教大家怎么样用listview异步加载图片,因为这样的文章在网上已经有很多了,比如这位仁兄写的就很好: http://www.iteye.com/topic/685986 我也是因为看 ...
- Jquery实现逐屏加载图片
引用jquery.scrollLoading.js $(document).ready(function () { //实现图片慢慢浮现出来的效果 $("img").load(fu ...
- 使用ViewPager实现自动轮播
很多APP中都实现了类似引导页的自动轮播,不由得想到昨天的引导页上修改一下代码实现轮播. 其实大体上只需要添加一个线程循环执行就可以了. 项目已同步至:https://github.com/nanch ...
- 【转】Android循环滚动广告条的完美实现,封装方便,平滑过渡,从网络加载图片,点击广告进入对应网址
Android循环滚动广告条的完美实现,封装方便,平滑过渡,从网络加载图片,点击广告进入对应网址 关注finddreams,一起分享,一起进步: http://blog.csdn.net/finddr ...
- AJ学IOS(11)UI之图片自动轮播
AJ分享,必须精品 先看效果 代码 #import "NYViewController.h" #define kImageCount 5 @interface NYViewCont ...
- android ImageView网络图片加载、动态设置尺寸、圆角..
封装了一个关于ImageView的辅助类,该类可以方便实现网络图片下载的同时,动态设置图片尺寸.圆角.....一系列连贯的操作,无样式表,java代码实现所有功能,使用很方便. package com ...
随机推荐
- jQuery中 end(); 的用法
jQuery中的end()方法的意思 选取某个元素,查找选取其子元素,然后再回过来选取这个元素.用例子说明了一下: 比如HTML代码: <p><span>Hello</s ...
- 2016年3月AV评测
- explain分析查询
参考以下文章,在此非常感谢原作者 explain分析查询
- 重拾java系列一java基础(1)
前言,不知不觉,从接触java到工作至今已有两年的时间,突然感觉自己的基础知识还很薄弱,有些知识虽然知道,但是停留在表面上,没有深挖,或者实践过,感觉掌握的很肤浅,而且时间一长,就觉得忘记了,我觉得这 ...
- hadoop中Text类 与 java中String类的区别
hadoop 中 的Text类与java中的String类感觉上用法是相似的,但两者在编码格式和访问方式上还是有些差别的,要说明这个问题,首先得了解几个概念: 字符集: 是一个系统支持的所有抽象字符的 ...
- 嵌入式 -- WINKHUB 边信道攻击 (NAND Glitch)
0x00 前言 随着物联网IOT的飞速发展,各类嵌入式设备, 路由器安全研究也越来越火. 但因为跟以往纯软件安全研究的要求不同, 这类研究往往需要结合相应的硬件知识. 很多朋友困惑如何开始, 甚至卡在 ...
- 使用respondsToSelector:来发现对象是否响应消息
发现对象是否响应消息 要发现一个对象是否响应一则消息,请在该对象上调用 respondsToSelector: 方法.应用程序代码通常验证一个对象响应一则消息后,才将消息发送给该对象. if ([it ...
- php大力力 [003节]php在百度文库的几个基础教程mac环境下文本编辑工具
2015-08-22 php大力力003.mac环境下文本编辑工具 在windows下,使用notepad特别多.在mac下使用“备忘录”app,word,反而没有存储过txt后缀等不同文本. mac ...
- 最熟悉的陌生人:ListView 中的观察者模式
RecyclerView 得宠之前,ListView 可以说是我们用的最多的组件.之前一直没有好好看看它的源码,知其然不知其所以然. 今天我们来窥一窥 ListView 中的观察者模式. 不熟悉观察者 ...
- 7、C#基础整理(类)
String类 概念:是一个class类型的类,里面包含许多处理字符串的方法和属性 1.length方法. 例: string s = "hello"; Console.Write ...