核心代码:
// ListView的单击事件 imgListView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { // 加载图片预览 BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = 2; bitmap = BitmapFactory.decodeFile(pathsList.get(arg2), options); preImage.setImageBitmap(bitmap); // String msg = ""; // for (int i = 0; i < isSelected.size(); i++) { // if (isSelected.get(i) == true) { // msg = msg + pathsList.get(i) + "第" + i + "张" + "\n"; // } // } // // ShowMsg.showToast(getApplicationContext(), handler, msg); /******* 直接点击ListView设置checkbox ********/ // ViewHolder vHollder = (ViewHolder) arg1.getTag(); // 在每次获取点击的item时将对于的checkbox状态改变,同时修改map的值。 // vHollder.checkBox.toggle();// 反转当前视图的选中状态 // 点击预览 // String text = ""; // String select_id = ""; // if (vHollder.checkBox.isChecked() == true) { // isSelect[arg2] = true; // // } else { // isSelect[arg2] = false; // } // // for (int i = 0; i < isSelect.length; i++) { // if (isSelect[i]) { // 如果该选项被选中 // text = text + pathsList.get(i) + "第" + i + "张" + "\n"; // select_id = select_id + i + ";"; // Toast.makeText(getApplicationContext(), // "选中了:\n" + text, 5000).show(); // } // } // hasSelect = select_id; // ListPicAdapter.isSelected.put(arg2, vHollder.checkBox // .isChecked()); } });
public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder = null; // convertView为null的时候初始化convertView。 if (convertView == null) { holder = new ViewHolder(); convertView = mInflater.inflate(R.layout.listphoto, null); holder.filename = (TextView) convertView .findViewById(R.id.filename); holder.imageView = (ImageView) convertView.findViewById(R.id.image); holder.checkBox = (CheckBox) convertView.findViewById(R.id.cb); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } holder.filename.setText(SDCard.getName(imgPaths.get(position))); holder.imageView.setImageBitmap(photos.get(position).getBitmap()); holder.checkBox.setChecked(isSelected.get(position)); final CheckBox checkBox = holder.checkBox; final int arg2 = position; checkBox.setChecked(isSelected.get(position)); checkBox.setOnClickListener(new OnClickListener() { public void onClick(View v) { // 记录CheckBox的状态 if (isSelected.get(arg2)) { isSelected.put(arg2, false); } else { isSelected.put(arg2, true); } notifyDataSetChanged(); } }); checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { } }); return convertView; }
apt-get install yum
./configure -prefix=/usr/local
sudo apt-get --reinstall install ttf-dustin khangman kdeedu kde
ln -s /usr/local/lib/libevent-2.0.so.5 /lib/libevent-2.0.so.5
./memcached -d -m 64 -p 11211 -l 127.0.0.1 -u nobody -c 1024
memcache 的安装会报没有编译器所以应该首先安装gcc
gcc的安装方法为 sudo apt-get install build-essential
然后在安装memcache安装之前要先安装libevent
下载地址为
wget http://www.monkey.org/~provos/libevent-2.0.10-stable.tar.gz
下载后使用wget http://www.monkey.org/~provos/libevent-2.0.13-stable.tar.gz
tar xzvf libevent-2.0.13-stable.tar.gz
./configure
make
make install安装Memcached
wget http://memcached.googlecode.com/files/memcached-1.4.7.tar.gz
tar xvzf memcached-1.4.7.tar.gz
cd memcached-1.4.7
./configure --prefix=/usr/local/memcached/
make
make install
方式安装即可。
http://www.linuxidc.com/Linux/2011-11/47951.htm