use of org.yh.library.ui.BindView in project YhLibraryForAndroid by android-coco.
the class DemoActivity method initWidget.
@Override
public void initWidget() {
super.initWidget();
changeFragment(R.id.content, oneFragment);
FloatingActionButton fab = bindView(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG).setAction("Action", null).show();
}
});
drawer = bindView(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
// 禁止手势滑动
drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
// 打开手势滑动
// drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
toggle.syncState();
// 导航图标
// toolbar.setNavigationIcon(R.mipmap.ic_launcher);
NavigationView navigationView = bindView(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
navigationView.getMenu().getItem(0).setChecked(true);
// NavigationView navigationView1 =bindView(R.id.nav_view1);
// navigationView1.setNavigationItemSelectedListener(this);
// navigationView1.getMenu().getItem(0).setChecked(true);
// lineartlayout
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
// CardView
// 两列
// int spanCount = 3;
// GridLayoutManager layoutManager = new GridLayoutManager(this,spanCount);
// layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
// StaggeredGridLayoutManager 不能加分割线
// StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager(spanCount,
// StaggeredGridLayoutManager.VERTICAL);
// 分割线为LinearLayoutManager
// 分割线
mRecyclerView.addItemDecoration(mRecyclerView.new YHItemDecoration());
mRecyclerView.setLayoutManager(layoutManager);
// mRecyclerView.setEmptyView(empty_layout);//没有数据的空布局
// 可以自定义下拉刷新的样式
mRecyclerView.setRefreshProgressStyle(ProgressStyle.BallPulseRise);
// 可以自定义上拉加载的样式
mRecyclerView.setLoadingMoreProgressStyle(ProgressStyle.SquareSpin);
mRecyclerView.setFootViewText(getString(R.string.listview_loading), "我是有底线的。");
// 箭头
mRecyclerView.setArrowImageView(R.mipmap.iconfont_downgrey);
// View header = LayoutInflater.from(this).inflate(R.layout.recyclerview_header, (ViewGroup)findViewById(android.R.id.content),false);
// mRecyclerView.addHeaderView(header);
// View header1 = LayoutInflater.from(this).inflate(R.layout.recyclerview_header, (ViewGroup)findViewById(android.R.id.content),false);
// mRecyclerView.addHeaderView(header1);
// header1.setBackgroundColor(0xff556B2F);
// View header2 = LayoutInflater.from(this).inflate(R.layout.recyclerview_header, (ViewGroup)findViewById(android.R.id.content),false);
// mRecyclerView.addHeaderView(header2);
// header2.setBackgroundColor(0xff1874CD);
mAdapter = new MyRecyclerAdatpter();
mRecyclerView.setAdapter(mAdapter);
mAdapter.setOnItemClickListener(this);
mRecyclerView.setLoadingListener(new YHRecyclerView.LoadingListener() {
@Override
public void onRefresh() {
page = 1;
// 必须在数据更新前清空,不能太早
mAdapter.getDatas().clear();
getDataByLine();
}
@Override
public void onLoadMore() {
page++;
if (page <= TOTAL_PAGE) {
// 小于总页数就加载更多
// loading more
getDataByLine();
} else {
// the end
mRecyclerView.setNoMore(true);
}
}
});
mRecyclerView.refresh();
}
Aggregations