所以我有一个片段,它有一个tablayout viewpager,它由两个选项卡 - 两个片段组成。RecyclerView里面ViewPager片段不显示
的事情是,recyclerview显示空的,我不知道为什么,
标签片段布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/my_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
标签片段:
List<OrderListItem> orderList = new ArrayList<>();
orderList.add(new OrderListItem(333, "ABCDE", new Date(), new Date(), false, true));
adapter = new OrderListAdapter(orderList, this.getActivity());
layoutManager = new LinearLayoutManager(this.getActivity(), LinearLayoutManager.VERTICAL, false);
myRecyclerView.setLayoutManager(layoutManager);
myRecyclerView.setAdapter(adapter);
适配器:
public class OrderListAdapter extends RecyclerView.Adapter<OrderListAdapter.ViewHolder>{
private List<OrderListItem> orderList;
@LayoutRes
private final int layoutRes;
private Context context;
private final LayoutInflater inflater;
public OrderListAdapter(List<OrderListItem> orderList, Context context){
this.orderList = orderList;
this.layoutRes = R.layout.order_list_item_layout;
this.context = context;
inflater = LayoutInflater.from(this.context);
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = inflater.inflate(layoutRes, parent, false);
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
final OrderListItem item = orderList.get(position);
}
public void setItems(List<OrderListItem> orderList){
this.orderList.clear();
this.orderList.addAll(orderList);
notifyDataSetChanged();
}
@Override
public int getItemCount() {
return orderList.size();
}
public static class ViewHolder extends RecyclerView.ViewHolder {
public ViewHolder(View itemView) {
super(itemView);
}
}
}
Recy cleView项目一些丰富多彩的布局内幕,所以我知道如果孩子布局是否存在,它不是。任何想法为什么recyclerview是空的?
edit1:我知道recyclerview在那里,因为它在一个lolipop手机中,并且如果我在回收站进行移动,它会向我显示波纹顶部和底部滚动边界。但孩子的布局是空的和空白的,应该是多彩的,因为我在孩子的布局中具体化。
eit2。只是用一个简单的适配器的列表视图,它正在显示。一定有什么车与休旅车
EDIT3:行布局(我应该清楚地看到一个空的TextView有彩色,除了没有任何值设置好的。)
<LinearLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:background="@color/black"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/material_deep_teal_200"
android:text="New Text"
android:id="@+id/textView" />
</LinearLayout>
我还不,因为我无法设置c要显示的项目。我的子项目布局有一些颜色,所以我知道它是否显示。目前没有设置任何东西,但这不是重点,如果是的话,它仍然不会显示 –
那么任何建议? –
@ user3806331发布完成的单元格 –