您的位置:首页 > 移动开发

recyclerview,AppBarLayout,Toolbar,CoordinatorLayout 的结合使用~

2016-11-17 11:01 423 查看
import android.app.Activity;
import android.os.Bundle;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CoordinatorLayout;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.wuxiaolong.pullloadmorerecyclerview.PullLoadMoreRecyclerView;
import com...R;
import com...school.main.adapter.AttenDanceBabyAdaper;
import com...util.ToastUtil;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
* author : Created by snake_son  on 2016/11/17.
* mail:643435675@qq.com
* motto:i’ll love you as long as i live
*/

public class AppBarLayoutTest extends Activity {
@BindView(R.id.tv_teacher_noattence)
TextView tvTeacherNoattence;
@BindView(R.id.tv_teacher_attence)
TextView tvTeacherAttence;
@BindView(R.id.tv_teacher_vacate)
TextView tvTeacherVacate;
@BindView(R.id.ll_three)
LinearLayout llThree;
@BindView(R.id.appbar)
AppBarLayout appbar;
@BindView(R.id.attence_teacher_recycleview)
PullLoadMoreRecyclerView attenceTeacherRecycleview;
@BindView(R.id.content)
CoordinatorLayout content;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_attence_baby);
ButterKnife.bind(this);
attenceTeacherRecycleview.setLinearLayout();
attenceTeacherRecycleview.setAdapter(new AttenDanceBabyAdaper());
attenceTeacherRecycleview.setOnPullLoadMoreListener(new PullLoadMoreRecyclerView.PullLoadMoreListener() {
@Override
public void onRefresh() {
attenceTeacherRecycleview.setPullLoadMoreCompleted();
}

@Override
public void onLoadMore() {
ToastUtil.ShowToast(AppBarLayoutTest.this,"加载完成");
}
});
}
}

xml文件:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true">

<!--<android.support.v7.widget.Toolbar-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="wrap_content"-->
<!--app:layout_scrollFlags="scroll|enterAlwaysCollapsed" />-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_scrollFlags="scroll|enterAlwaysCollapsed"
>

<include layout="@layout/comment_title"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="80dp"
>
<ImageView
android:layout_centerInParent="true"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="@drawable/icon_default"/>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/ll_three"
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="@color/littler_line"
android:gravity="center"
android:orientation="horizontal"
android:visibility="visible">

<TextView
android:id="@+id/tv_teacher_noattence"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="未到(2)" />

<TextView
android:id="@+id/tv_teacher_attence"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="已到(2)" />

<TextView
android:id="@+id/tv_teacher_vacate"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="请假(2)" />
</LinearLayout>
</android.support.design.widget.AppBarLayout>

<com.wuxiaolong.pullloadmorerecyclerview.PullLoadMoreRecyclerView
android:id="@+id/attence_teacher_recycleview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/appbar"
android:layout_margin="10dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐