RecyclerView-Tutorial

RecyclerView 介绍

官方文档:RecyclerView
RecycleView 是google的v7 包中用来替代ListView,其中直接拥有缓存模块ViewHolder。里面包含的LayoutManager 可以很方便的实现ListView,GridView,下拉刷新。ItemAnimation也很好的实现了每个Item的特效。

Android ListView性能优化

  1. 使用Adapter提供的convertView
    convertView是Adapter提供的视图缓存机制,当第一次显示数据的时候, adapter会创建n个(n等于页面可见的item的数目) convertView,当下次需要显示新的item的时候, adapter会循环利用这些已经创建的convertView, 減少再次创建convertView所带来的开销,从而达到性能的提升。

Android AutoCompleteTextView&MultiAutoCompleteTextView

在Android中提供了两种智能输入框,它们是AutoCompleteTextView、MultiAutoCompleteTextView。它们的功能大致一样。显示效果像Google搜索一样,当你在搜索框里输入一些字符时(至少两个字符),会自动弹出一个下拉框提示类似的结果。下面详细介绍一下。

AutoCompleteTextView

Android CheckBox&RadioButton

CheckBox和RadioButton控件都只有选中和未选中状态,不同的是RadioButton是单选按钮,需要编制到一个RadioGroup中,同一时刻一个RadioGroup中只能有一个按钮处于选中状态。
以下为CheckBox和RadioButton常用方法及说明

以下为单选按钮和复选按钮的使用方法
目录结构

main.xml布局文件

Android ToggleButton

ToggleButton的状态只能是选中和未选中,并且需要为不同的状态设置不同的显示文本。
以下案例为ToggleButton的用法
目录结构

main.xml布局文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<ImageView android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/bulb_off"
android:layout_gravity="center_horizontal" />

<ToggleButton android:id="@+id/toggleButton"
android:layout_width="140dip"
android:layout_height="wrap_content"
android:textOn="开灯"
android:textOff="关灯"
android:layout_gravity="center_horizontal" />

</LinearLayout>

Android DatePicker&TimePicker

DatePicker继承自FrameLayout类,日期选择控件的主要功能是向用户提供包含年、月、日的日 期数据并允许用户对其修改。如果要捕获用户修改日期选择控件中的数据事件,需要为DatePicker添加OnDateChangedListener监听器。

TimePicker也继承自FrameLayout类。时间选择控件向用户显示一天中的时 间(可以为24小时,也可以为AM/PM制),并允许用户进行选择。如果要捕获用户修改时间数据的事件,便需要为TimePicker添加 OnTimeChangedListener监听器
以下模拟日期与时间选择控件的用法
目录结构

Jquery自定义插件

Jquery 自定义插件

平时看到的Jquery插件都是 $(“xxx”).my_plugin()这样子就能使用。对于jquery来说自定义插件非常方便,只需要实现 $.fn.my_plugin这种类型的方法就可以。

在这里我们实现一个瀑布流的产品选择器