Introduction to AQuery – Android Query 翻译

来源:互联网 发布:华为软件流程 编辑:程序博客网 时间:2024/05/03 07:24

Introduction to AQuery – Android Query 翻译

原文地址:AQuery Library Documentation

Introduction to AQuery(AQuery简介)

  • Android-Query (AQuery) is a light-weight library for doing asynchronous tasks and manipulating UI elements in Android in efficient way. The main goal of AQuery library is to make Android coding simpler, easier, and more fun. It allows developer to write less code to do lot more.
  • Android-Query是一个高效执行异步任务与操作UI元素的轻量级库。AQuery主要目的是使安卓编程更加简单,容易,有趣。它能使开发者写更少代码,做更多的事。

Less Code(更少代码)

  • AQuery allows the developer to be more expressive in terms of writing code i.e., write-less/do-more. Simpler code is always easier to read and maintain.
  • AQuery使开发者写的代码更加简单,易读与维护。

TextView与Button的使用实例:

public void onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);    setContentView(R.layout.test);                      aq = new AQuery(this);                  aq.id(R.id.text).text("Hello");                  aq.id(R.id.button).text("Click Me").clicked(this, "buttonClicked");}public void buttonClicked(View button){        //update the text        aq.id(R.id.text).text("Hello World");}

AJAX Callback(AJAX回调)

  • Asynchronous AJAX or RPC calls are made simple with built in methods and it supports following types:
  • 内嵌方法异步AJAX回调支持以下数据类型:

    • JSONObject
    • JSONArray
    • String (HTML, XML)
    • XmlDom (XML parsing)
    • XmlPullParser (Large XML files)
    • byte array
    • User defined custom type (Transformer)
    • Bitmap

Image Loading(图片加载)

  • AQuery library supports easy asynchronous image loading from network, with automatic file and memory caching. Best of it’s image loading features are:
  • AQuery库支持从网路异步加载图片,自动文件与类存缓存。图片加载的特性:

    • Simple Loading
    • Memory & File Caching
    • Down Sampling
    • Zoomable (WebView)
    • Fallback Image
    • Preloading
    • Animation
    • Dynamic Aspect Ratio
    • Avoid Duplicated Simultaneous Fetches
    • Custom Callback

XML Parsing(XML解析)

  • AQuery library provides a light weight XML parser called XmlDom.
  • AQuery库提供轻量级xml解析:XmlDom

  • XmlDom is simple and can be used for doing XML parsing.

  • XmlDom是一个简单的XML解析库

Chaining(链接)

  • AQuery library designed set methods in such a way that it will return itself, so it is quite easy for developers to chain set methods. Here is an example:
  • AQuery库的set方法被设计为返回自己本身,所以开发者可以方便的连续使用。
String name = "AQuery is a simple Android Library";aq.id(R.id.txtname).text(name).background(R.color.red).textColor(R.color.black).enabled(true).visible();

Binding(绑定)

  • AQuery makes binding listeners to views simple and easy. Here is an example:
  • AQuery使绑定监听器到组件十分简单容易
@Overrideprotected void onCreate(Bundle savedInstanceState){        //set content view here...        AQuery aq = new AQuery(this);           aq.id(R.id.button).clicked(this, "buttonClicked");        aq.id(R.id.list).itemClicked(this, "itemClicked")}public void buttonClicked(View view){        //a button is clicked}public void itemClicked(AdapterView<?> parent, View v, int pos, long id) {        //list item is clicked}

Authentication(授权)

  • AQuery provides an easy and simple authentication mechanism for Google and other Auth enabled services.
  • AQuery为谷歌和其它验证的服务提供权限机制

Multiple UI, One Piece of Code(一段代码对应多个UI布局)

  • With the advent of new Tablet devices, Android apps will need to support a wider range of screen sizes. Developers might need to design different UI layout for phone and tablets, but do we need to write a different set of code also?
  • 随着新平板设备的出现,安卓软件将需要支持大范围的屏幕尺寸。开发者可能需要给手机和平板设计不同的UI布局,但是我们需要为它们写新的代码么?

  • AQuery allows developers to manage different layouts with the same piece of code. If a view is not in a layout, AQuery will just ignore all the operations performed on the view.

  • AQuery允许开发者们使用相同的代码管理不同布局。如果一个组件不在布局中,AQuery将忽略这个组件的操作。*

Light Weight(轻量)

  • Memory is scarce for mobile apps. The AQuery lib is standalone and relatively small and optimized with proguard (~60k). The actual increase in apk size will be even smaller.
  • 内存对于手机软件是十分珍贵的。AQuery库是独立相对较小并且效率最大化。因使用AQuery而增加的apk大小相对其它框架更加小。

Non-intrusive(无冲突)

  • AQuery has no dependency and does not require developers to inherit specialized views or activities. Developers are free to use AQuery along with any other library without any conflict.
  • AQuery是独立的并且不需要开发者们继承特定的组件或Activity。AQuery与其它框架不冲突。

阅读资料

  • AQuery Library Documentation
  • Most Popular Android App Development Framework
  • AQuery Image Loading
0 0