首页 文章 精选 留言 我的

精选列表

搜索[文档处理],共10000篇文章
优秀的个人博客,低调大师

Android2.2 r1 API 中文文档系列(10) —— CheckBox

正文 一、类结构 public class CheckBox extends CompoundButton java.lang.Object android.view.View android.widget.TextView android.widget.Button android.widget.CompoundButton android.widget.CheckBox 二、 概述 复选框是一种有双状态按钮的特殊类型,可以选中或者不选中。如下是一个在activity中使用复选框的例子: 本文转自over140 51CTO博客,原文链接:http://blog.51cto.com/over140/582697,如需转载请自行联系原作者

优秀的个人博客,低调大师

关于安卓图像显示比iOS差的原因(英文文档

There are so many comparations between Android phone and iPhone. We cannot make the conclusion about which one is better, but we all knows that the image quality of Android phone is much worse than iPhone. No matter you are using Facebook, Twitter or even Instagram, after taking the photo, adding a filter, then sharing to the social network, the images produced by Android phone are always coarse. Why? Our team had been working on this issue in the last year. After very deep research, we found that this was a "TINY" mistake made by Google. Although tiny, but the influence was very huge (all Android Apps related to image), and lasted till today. The problem is : libjpeg. We all know that libjpeg is widely used open source JPEG library. Android also uses libjpeg to compress images. After digging into the source code of Android, we can find that instead of using libjpeg directly, Android is based on an open source image engine called Skia. The Skia is a wonderful engine maintained by Google himself, all image functions are implemented in it, and it is widely used by Google and other companies' products (e.g.: Chrome, Firefox, Android......). The Skia has a good encapsulation of libjpeg, you can easily develop image utilites base on this engine. When using libjpeg to compress images, optimize_coding is a very important parameter. In libjpeg.doc, we can find following introductions about this parameter: boolean optimize_coding TRUE causes the compressor to compute optimal Huffman coding tables for the image. This requires an extra pass over the data and therefore costs a good deal of space and time. The default is FALSE, which tells the compressor to use the supplied or default Huffman tables. In most cases optimal tables save only a few percent of file size compared to the default tables. Note that when this is TRUE, you need not supply Huffman tables at all, and any you do supply will be overwritten. As the libjpeg.doc, we now know that because setting the optimize_coding to TRUE may cost a good deal of space and time, the default in libjpeg is FALSE. Everything seems fine about the doc, and libjpeg is very stable. But many people ignored that this document was writen for more than 10 years. At that time, space and computing abilities are very limited. With today's modern computers or even mobile phones, this is not an issue. On the contrary, we should pay more attention to the image quality (retina screens) and image size (cloud services). Google's engineers of skia project did not set this parameter, so the optimize_coding in Skia was remained to FALSE as the default value, and Skia concealed this setting, you could not change the setting outside of Skia. This became to a big problem, we had to endure worse image and bigger file size. Our team had tested optimize_coding for many different images. If you want the same quality of image compressing, the file size are 5-10 times bigger when setting the optimze_coding to FALSE than to TRUE. The difference is quite significant. We also compared the jpeg compressing between iOS and Android (they both concealed the optimize_coding parameter). With the same original images, if you want same quality level, you need 5-10 times file size on Android. The result is clear, Apple does know the importance of optimize_coding and Huffman tables and Google does not. (Apple uses their own Huffman table algorithm, not like libjpeg or libjpeg-turbo. It seems that Apple has done more tuning works on image compressing.) Finally, we decided not to use JPEG compress functions provided by Android, and we compiled our own native library based on libjpeg-turbo (libjpeg-turbo also has performance improvements). Now we can save 5-10 times of image space and enjoy the same or even better image quality. This work is totally worth to do. Thanks for reading, :) Our project on github: https://github.com/bither

优秀的个人博客,低调大师

android XMl 解析神奇xstream 六: 把集合list 转化为 XML文档

前言:对xstream不理解的请看: android XMl 解析神奇xstream 一: 解析android项目中 asset 文件夹 下的 aa.xml 文件 android XMl 解析神奇xstream 二: 把对象转换成xml android XMl 解析神奇xstream 三: 把复杂对象转换成 xml android XMl 解析神奇xstream 四: 将复杂的xml文件解析为对象 android XMl 解析神奇xstream 五: 把复杂对象转换成 xml ,并写入SD卡中的xml文件 1、创建JavaBeen package com.android10; public class Person { String pName ; String pAge ; public String getpName() { return pName; } public void setpName(String pName) { this.pName = pName; } public String getpAge() { return pAge; } public void setpAge(String pAge) { this.pAge = pAge; } } package com.android10; public class Product { private String name ; private String age ; private Person person ; public String getName() { return name; } public void setName(String name) { this.name = name; } public String getAge() { return age; } public void setAge(String age) { this.age = age; } public Person getPerson() { return person; } public void setPerson(Person person) { this.person = person; } } package com.android10; import java.util.List; public class ListBean { private List<Product> root ; public List<Product> getRoot() { return root; } public void setRoot(List<Product> root) { this.root = root; } } 2、主要方法 package com.android10; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.util.ArrayList; import java.util.List; import javax.xml.transform.OutputKeys; import javax.xml.transform.Source; import javax.xml.transform.Transformer; import javax.xml.transform.sax.SAXSource; import javax.xml.transform.sax.SAXTransformerFactory; import javax.xml.transform.stream.StreamResult; import org.xml.sax.InputSource; import android.app.Activity; import android.os.Bundle; import com.thoughtworks.xstream.XStream; public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView( R.layout.activity_main ); XStream xstream = new XStream() ; List<Product> root = getList() ; //将ListBean中的集合设置空元素,即不显示集合元素标签 xstream.addImplicitCollection( ListBean.class, "root"); xstream.autodetectAnnotations(true); //设置别名 xstream.alias( "product", Product.class ); //将name设置为父类(Student)的元素的属性 xstream.useAttributeFor( Product.class, "name" ); //把list集合转换成Xml字符串 String xmlString = xstream.toXML( root ) ; //把Xml字符串写入SD卡Xml文件 XstreamUtil xstreamUtil = new XstreamUtil() ; xstreamUtil.writeToXml( this , xmlString ) ; //把Xml字符串转化成list集合 List<Product> list = new ArrayList<Product>() ; list = (List<Product>) xstream.fromXML( xmlString ) ; System.out.println("sss"+ formatXml( xmlString ) ); } /** * 得到数据 * @return */ private List<Product> getList(){ Person person1 = new Person() ; person1.setpName( "saliy" ) ; person1.setpAge( "36" ); Product product1 = new Product() ; product1.setName( "jhon" ) ; product1.setAge( "30" ); product1.setPerson( person1 ); Person person2 = new Person() ; person2.setpName( "saliy02" ) ; person2.setpAge( "3602" ); Product product2 = new Product() ; product2.setName( "jhon02" ) ; product2.setAge( "3002" ); product2.setPerson( person2 ); List<Product> root = new ArrayList<Product>() ; root.add( product1 ) ; root.add( product2 ) ; return root ; } /** * 格式化XML字符串 * @param xml * @return */ public static String formatXml(String xml){ try{ Transformer serializer= SAXTransformerFactory.newInstance().newTransformer(); serializer.setOutputProperty(OutputKeys.INDENT, "yes"); serializer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); Source xmlSource=new SAXSource(new InputSource(new ByteArrayInputStream(xml.getBytes()))); StreamResult res = new StreamResult(new ByteArrayOutputStream()); serializer.transform(xmlSource, res); return new String(((ByteArrayOutputStream)res.getOutputStream()).toByteArray()); }catch(Exception e){ return xml; } } } package com.android10; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; import android.content.Context; import android.os.Environment; public class XstreamUtil { XcallBack xcallBack ; /** * 把xml字符串写入SD卡文件 * @param context * @param str xml字符串 */ public void writeToXml(Context context, String str ){ //获取文件路径 String SDPATH = Environment.getExternalStorageDirectory() + "/myfile1.xml/" ; //创建文件 File file = new File( SDPATH ) ; if( !file.exists() ){ try { file.createNewFile() ; } catch (IOException e) { e.printStackTrace(); } } //写入数据 try { FileOutputStream out = new FileOutputStream( file ) ; OutputStreamWriter outw = new OutputStreamWriter(out); try { outw.write(str); outw.close(); out.close(); if( xcallBack != null ){ xcallBack.success(); } } catch (IOException e) { if( xcallBack != null ){ xcallBack.fail(); } } } catch (FileNotFoundException e1) { e1.printStackTrace(); if( xcallBack != null ){ xcallBack.fail(); } } } //设置监听器 void setXStreamLister( XcallBack xcallBack ){ this.xcallBack = xcallBack ; } } interface XcallBack{ /** * 写入成功 */ void success() ; /** * 写入失败 */ void fail() ; } 3、运行结果 <list> <product name="jhon"> <age>30</age> <person> <pAge>36</pAge> <pName>saliy</pName> </person> </product> <product name="jhon02"> <age>3002</age> <person> <pAge>3602</pAge> <pName>saliy02</pName> </person> </product></list>

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册