|
|
|
@ -6,6 +6,7 @@ import android.view.View;
|
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
|
|
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
|
import androidx.cardview.widget.CardView;
|
|
|
|
|
import androidx.fragment.app.Fragment;
|
|
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
|
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
|
|
@ -22,6 +23,7 @@ public class RecyclerViewFragment extends Fragment {
|
|
|
|
|
static final int ITEMS = 3;
|
|
|
|
|
|
|
|
|
|
RecyclerView mRecyclerView;
|
|
|
|
|
CardView mCardView;
|
|
|
|
|
@Override
|
|
|
|
|
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
|
|
|
|
return inflater.inflate(R.layout.fragment_recyclerview, container, false);
|
|
|
|
@ -29,16 +31,27 @@ public class RecyclerViewFragment extends Fragment {
|
|
|
|
|
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
|
|
|
|
super.onViewCreated(view, savedInstanceState);
|
|
|
|
|
mRecyclerView=view.findViewById(R.id.recyclerView);
|
|
|
|
|
// mCardView = view.findViewById();
|
|
|
|
|
//需要根据网路请求发送数据,来请求一个页可以有多少文章条目,而且针对每一个tab,都要有不同的显示方式
|
|
|
|
|
for (int i=0;i<ITEMS;i++){
|
|
|
|
|
items.add(new Object());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
|
|
|
|
|
//设置布局
|
|
|
|
|
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
|
|
|
|
|
linearLayoutManager.canScrollVertically();
|
|
|
|
|
mRecyclerView.setLayoutManager(linearLayoutManager);
|
|
|
|
|
|
|
|
|
|
mRecyclerView.setHasFixedSize(true);
|
|
|
|
|
//设置分割线
|
|
|
|
|
mRecyclerView.addItemDecoration(new MaterialViewPagerHeaderDecorator());
|
|
|
|
|
//设置适配器
|
|
|
|
|
mRecyclerView.setAdapter(new RecyclerViewPagerAdapter(items));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
public void initdata(){
|
|
|
|
|
//初始化数据类,请求网络
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|