AQuery学习笔记(一)

一、AQuery对象(两官方的两句话来介绍,英文很烂,写出大概我理解的意思)

  官方对AQuery对象的说明.

  There's only 1 main class in AQuery. That is, the AQuery class.

  AQuery object has two states: "root" and the "view".

  大概意思:只有一个主类,就是AQuery类,这个类有两种状态root和view;

   AQuery usage:

  1. Create an AQuery object with an activity, the root view of a fragment, a list item view (or any view container), or a context (for background ajax requests)
  2. Use the id() or find() methods to pick the current "view"
  3. Call the appropriate methods to update the view

     大概意思:AQuery对的root view(根视图),可以是一个Activity、fragment、Context或者是任意一个容器视图(如LinearLayout),

                   使用AQuery对象的id()或者find()方法调用一个View为当前操作的View,

        如:aquery.id(R.id.textView1).text("xxxxx");

        也可以是: aquery.id(R.id.textView1);

                                 aquery.text("xxxx");

                   上面两个示例结果一样,都是操作R.id.textView1的View.

 

二、 AQuery简单的应用 

AQuery aq = new AQuery(this);
//加载id为tv1的TextView控件,并设置text属性值
aq.id(R.id.tv1).text("fuck you!");
//加载一个imageView控件,并设置背景图片
aq.id(R.id.imageView1).image(
R.id.logo);
//加载一个View,为当前操作的View aq.id(R.id.imageView2);
if(aq.isExist()){//判断这个是View是否存在,如果存在就返回true
  //aq.getImageView()是得到当前操作的View,并转换为ImageView.   ImageView iv
= aq.getImageView();   iv.setBackgroundResource(R.drawable.logo2);
}

 

 

posted @ 2013-01-26 15:35  左眼跳跳  阅读(2094)  评论(0编辑  收藏  举报