// Path: recyclerviewDemo/src/com/zhy/sample/demo_recyclerview/HomeAdapter.java
// public interface OnItemClickLitener
// {
// 	void onItemClick(View view, int position);
// 	void onItemLongClick(View view , int position);
// }
// 
// Path: recyclerviewDemo/src/com/zhy/sample/refresh/RefreshActivity.java
// public class RefreshActivity extends AppCompatActivity {
// 
// 	TextView tv;
// 	ScrollView scrollview;
// 	ListView listView;
// 	LinearLayout root;
// 	private List<String> mDatas;
// 	@Override
// 	protected void onCreate(Bundle savedInstanceState) {
// 		// TODO Auto-generated method stub
// 		super.onCreate(savedInstanceState);
// 		setContentView(R.layout.activity_refresh);
// 		
// 		tv=(TextView) findViewById(R.id.tv);
// 		scrollview=(ScrollView) findViewById(R.id.myScrollview);
// 		listView=(ListView) findViewById(R.id.listview);
// 		root=(LinearLayout) findViewById(R.id.root);
// 		initData();
// 		
// 		ArrayAdapter<String> adapter=new ArrayAdapter<String>(this, R.layout.item_home, R.id.id_num, mDatas);
// 		listView.setAdapter(adapter);
// 	}
// 
// 	protected void initData()
// 	{
// 		mDatas = new ArrayList<String>();
// 		for (int i = 'A'; i < 'Z'; i++)
// 		{
// 			mDatas.add("" + (char) i);
// 		}
// 	}
// 	
// 	
// 	
// 	public void refresh(View v) {
// 		
// 		if(!ViewCompat.canScrollVertically(v, -1)){
// 			Toast.makeText(this, "拉到顶部了", 0).show();
// 		}else{
// 			Toast.makeText(this, "没拉到顶部了", 0).show();
// 		}
// 
// 	}
// 
// 	public void loadmore(View v) {
// 		if(!ViewCompat.canScrollVertically(v, 1)){
// 			Toast.makeText(this, "拉到底部了", 0).show();
// 		}else{
// 			Toast.makeText(this, "没拉到底部了", 0).show();
// 		}
// 	}
// 	
// 	
// 	@Override
// 	public boolean onCreateOptionsMenu(Menu menu)
// 	{
// 		getMenuInflater().inflate(R.menu.men_fresh, menu);
// 		return super.onCreateOptionsMenu(menu);
// 	}
// 	
// 	
// 	@Override
// 	public boolean onOptionsItemSelected(MenuItem item){
// 		switch (item.getItemId()) {
// 		case R.id.id_action_refresh:
// 			refresh(root);
// 			break;
//        case R.id.id_action_more:
//     	    loadmore(root);
// 			break;
// 		default:
// 			break;
// 		}
// 		return true;
// 	}
// }


import java.util.ArrayList;
import java.util.List;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;
import com.zhy.sample.demo_recyclerview.HomeAdapter.OnItemClickLitener;
import com.zhy.sample.refresh.RefreshActivity;
package com.zhy.sample.demo_recyclerview;




public class HomeActivity extends AppCompatActivity
{

	private RecyclerView mRecyclerView;
	private List<String> mDatas;
	private HomeAdapter mAdapter;

	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_single_recyclerview);

		initData();

		mRecyclerView = (RecyclerView) findViewById(R.id.id_recyclerview);
		mAdapter = new HomeAdapter(this, mDatas);

		mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(4,
				StaggeredGridLayoutManager.VERTICAL));
		
		
		
		mRecyclerView.setAdapter(mAdapter);
		mRecyclerView.addItemDecoration(new DividerGridItemDecoration(this));
		
		// 设置item动画
		mRecyclerView.setItemAnimator(new DefaultItemAnimator());

		initEvent();

	}

	private void initEvent()
	{
// Path: recyclerviewDemo/src/com/zhy/sample/demo_recyclerview/HomeAdapter.java
// public interface OnItemClickLitener
// {
// 	void onItemClick(View view, int position);
// 	void onItemLongClick(View view , int position);
// }
// 
// Path: recyclerviewDemo/src/com/zhy/sample/refresh/RefreshActivity.java
// public class RefreshActivity extends AppCompatActivity {
// 
// 	TextView tv;
// 	ScrollView scrollview;
// 	ListView listView;
// 	LinearLayout root;
// 	private List<String> mDatas;
// 	@Override
// 	protected void onCreate(Bundle savedInstanceState) {
// 		// TODO Auto-generated method stub
// 		super.onCreate(savedInstanceState);
// 		setContentView(R.layout.activity_refresh);
// 		
// 		tv=(TextView) findViewById(R.id.tv);
// 		scrollview=(ScrollView) findViewById(R.id.myScrollview);
// 		listView=(ListView) findViewById(R.id.listview);
// 		root=(LinearLayout) findViewById(R.id.root);
// 		initData();
// 		
// 		ArrayAdapter<String> adapter=new ArrayAdapter<String>(this, R.layout.item_home, R.id.id_num, mDatas);
// 		listView.setAdapter(adapter);
// 	}
// 
// 	protected void initData()
// 	{
// 		mDatas = new ArrayList<String>();
// 		for (int i = 'A'; i < 'Z'; i++)
// 		{
// 			mDatas.add("" + (char) i);
// 		}
// 	}
// 	
// 	
// 	
// 	public void refresh(View v) {
// 		
// 		if(!ViewCompat.canScrollVertically(v, -1)){
// 			Toast.makeText(this, "拉到顶部了", 0).show();
// 		}else{
// 			Toast.makeText(this, "没拉到顶部了", 0).show();
// 		}
// 
// 	}
// 
// 	public void loadmore(View v) {
// 		if(!ViewCompat.canScrollVertically(v, 1)){
// 			Toast.makeText(this, "拉到底部了", 0).show();
// 		}else{
// 			Toast.makeText(this, "没拉到底部了", 0).show();
// 		}
// 	}
// 	
// 	
// 	@Override
// 	public boolean onCreateOptionsMenu(Menu menu)
// 	{
// 		getMenuInflater().inflate(R.menu.men_fresh, menu);
// 		return super.onCreateOptionsMenu(menu);
// 	}
// 	
// 	
// 	@Override
// 	public boolean onOptionsItemSelected(MenuItem item){
// 		switch (item.getItemId()) {
// 		case R.id.id_action_refresh:
// 			refresh(root);
// 			break;
//        case R.id.id_action_more:
//     	    loadmore(root);
// 			break;
// 		default:
// 			break;
// 		}
// 		return true;
// 	}
// }


// Path: recyclerviewDemo/src/com/zhy/sample/demo_recyclerview/HomeActivity.java
import java.util.ArrayList;
import java.util.List;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;
import com.zhy.sample.demo_recyclerview.HomeAdapter.OnItemClickLitener;
import com.zhy.sample.refresh.RefreshActivity;

package com.zhy.sample.demo_recyclerview;




public class HomeActivity extends AppCompatActivity
{

	private RecyclerView mRecyclerView;
	private List<String> mDatas;
	private HomeAdapter mAdapter;

	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_single_recyclerview);

		initData();

		mRecyclerView = (RecyclerView) findViewById(R.id.id_recyclerview);
		mAdapter = new HomeAdapter(this, mDatas);

		mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(4,
				StaggeredGridLayoutManager.VERTICAL));
		
		
		
		mRecyclerView.setAdapter(mAdapter);
		mRecyclerView.addItemDecoration(new DividerGridItemDecoration(this));
		
		// 设置item动画
		mRecyclerView.setItemAnimator(new DefaultItemAnimator());

		initEvent();

	}

	private void initEvent()
	{
		mAdapter.setOnItemClickLitener(new OnItemClickLitener()