应用程序崩溃在onCreaterViewHolder和onBindViewHolder上仅在Marshmallow上创建RecyclerView

时间:2018-06-16 14:36:44

标签: android android-recyclerview

堆栈跟踪:

  android.view.InflateException: 
  at android.view.LayoutInflater.inflate (LayoutInflater.java:551)
  at android.view.LayoutInflater.inflate (LayoutInflater.java:429)
  at us.emanon.timecard.MyWeekRecyclerViewAdapter.onCreateViewHolder (MyWeekRecyclerViewAdapter.java:36)
  at us.emanon.timecard.MyWeekRecyclerViewAdapter.onBindViewHolder (MyWeekRecyclerViewAdapter.java:16)
  at us.emanon.timecard.MyWeekRecyclerViewAdapter.onCreateViewHolder (MyWeekRecyclerViewAdapter.java:16)
  at us.emanon.timecard.MyWeekRecyclerViewAdapter.access$000 (MyWeekRecyclerViewAdapter.java:16)
  at android.support.v7.widget.RecyclerView$Adapter.createViewHolder (RecyclerView.java:6685)
  at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline (RecyclerView.java:5869)
  at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition (RecyclerView.java:5752)
  at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition (RecyclerView.java:5748)
  at android.support.v7.widget.LinearLayoutManager$LayoutState.next (LinearLayoutManager.java:2232)
  at android.support.v7.widget.LinearLayoutManager.layoutChunk (LinearLayoutManager.java:1559)
  at android.support.v7.widget.LinearLayoutManager.fill (LinearLayoutManager.java:1519)
  at android.support.v7.widget.LinearLayoutManager.onLayoutChildren (LinearLayoutManager.java:614)
  at android.support.v7.widget.RecyclerView.dispatchLayoutStep2 (RecyclerView.java:3812)
  at android.support.v7.widget.RecyclerView.dispatchLayout (RecyclerView.java:3529)
  at android.support.v7.widget.RecyclerView.onLayout (RecyclerView.java:4082)
  at android.view.View.layout (View.java:18014)
  at android.view.ViewGroup.layout (ViewGroup.java:5911)
  at android.support.constraint.ConstraintLayout.onLayout (ConstraintLayout.java:1855)
  at android.view.View.layout (View.java:18014)
  at android.view.ViewGroup.layout (ViewGroup.java:5911)
  at android.widget.LinearLayout.setChildFrame (LinearLayout.java:1742)
  at android.widget.LinearLayout.layoutVertical (LinearLayout.java:1585)
  at android.widget.LinearLayout.onLayout (LinearLayout.java:1494)
  at android.view.View.layout (View.java:18014)
  at android.view.ViewGroup.layout (ViewGroup.java:5911)
  at android.widget.RelativeLayout.onLayout (RelativeLayout.java:1080)
  at android.view.View.layout (View.java:18014)
  at android.view.ViewGroup.layout (ViewGroup.java:5911)
  at android.support.v4.widget.DrawerLayout.onLayout (DrawerLayout.java:1171)
  at android.view.View.layout (View.java:18014)
  at android.view.ViewGroup.layout (ViewGroup.java:5911)
  at android.widget.FrameLayout.layoutChildren (FrameLayout.java:344)
  at android.widget.FrameLayout.onLayout (FrameLayout.java:281)
  at android.view.View.layout (View.java:18014)
  at android.view.ViewGroup.layout (ViewGroup.java:5911)
  at com.android.internal.widget.ActionBarOverlayLayout.onLayout (ActionBarOverlayLayout.java:493)
  at android.view.View.layout (View.java:18014)
  at android.view.ViewGroup.layout (ViewGroup.java:5911)
  at android.widget.FrameLayout.layoutChildren (FrameLayout.java:344)
  at android.widget.FrameLayout.onLayout (FrameLayout.java:281)
  at com.android.internal.policy.PhoneWindow$DecorView.onLayout (PhoneWindow.java:3175)
  at android.view.View.layout (View.java:18014)
  at android.view.ViewGroup.layout (ViewGroup.java:5911)
  at android.view.ViewRootImpl.performLayout (ViewRootImpl.java:2784)
  at android.view.ViewRootImpl.performTraversals (ViewRootImpl.java:2477)
  at android.view.ViewRootImpl.doTraversal (ViewRootImpl.java:1544)
  at android.view.ViewRootImpl$TraversalRunnable.run (ViewRootImpl.java:7616)
  at android.view.Choreographer$CallbackRecord.run (Choreographer.java:911)
  at android.view.Choreographer.doCallbacks (Choreographer.java:686)
  at android.view.Choreographer.doFrame (Choreographer.java:622)
  at android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:897)
  at android.os.Handler.handleCallback (Handler.java:739)
  at android.os.Handler.dispatchMessage (Handler.java:95)
  at android.os.Looper.loop (Looper.java:148)
  at android.app.ActivityThread.main (ActivityThread.java:7422)
  at java.lang.reflect.Method.invoke (Method.java)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1230)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1120)
Caused by: android.view.InflateException: 
  at android.view.LayoutInflater.createView (LayoutInflater.java:657)
  at com.android.internal.policy.PhoneLayoutInflater.onCreateView (PhoneLayoutInflater.java:58)
  at android.view.LayoutInflater.onCreateView (LayoutInflater.java:706)
  at android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:774)
  at android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:716)
  at android.view.LayoutInflater.rInflate (LayoutInflater.java:847)
  at android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:810)
  at android.view.LayoutInflater.inflate (LayoutInflater.java:527)
  at android.view.LayoutInflater.inflate (LayoutInflater.java:429)
  at us.emanon.timecard.MyWeekRecyclerViewAdapter.onCreateViewHolder (MyWeekRecyclerViewAdapter.java:36)
  at us.emanon.timecard.MyWeekRecyclerViewAdapter.onBindViewHolder (MyWeekRecyclerViewAdapter.java:16)
  at us.emanon.timecard.MyWeekRecyclerViewAdapter.onCreateViewHolder (MyWeekRecyclerViewAdapter.java:16)
  at us.emanon.timecard.MyWeekRecyclerViewAdapter.access$000 (MyWeekRecyclerViewAdapter.java:16)
  at android.support.v7.widget.RecyclerView$Adapter.createViewHolder (RecyclerView.java:6685)
  at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline (RecyclerView.java:5869)
  at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition (RecyclerView.java:5752)
  at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition (RecyclerView.java:5748)
  at android.support.v7.widget.LinearLayoutManager$LayoutState.next (LinearLayoutManager.java:2232)
  at android.support.v7.widget.LinearLayoutManager.layoutChunk (LinearLayoutManager.java:1559)
  at android.support.v7.widget.LinearLayoutManager.fill (LinearLayoutManager.java:1519)
  at android.support.v7.widget.LinearLayoutManager.onLayoutChildren (LinearLayoutManager.java:614)
  at android.support.v7.widget.RecyclerView.dispatchLayoutStep2 (RecyclerView.java:3812)
  at android.support.v7.widget.RecyclerView.dispatchLayout (RecyclerView.java:3529)
  at android.support.v7.widget.RecyclerView.onLayout (RecyclerView.java:4082)
  at android.view.View.layout (View.java:18014)
  at android.view.ViewGroup.layout (ViewGroup.java:5911)
  at android.support.constraint.ConstraintLayout.onLayout (ConstraintLayout.java:1855)
  at android.view.View.layout (View.java:18014)
  at android.view.ViewGroup.layout (ViewGroup.java:5911)
  at android.widget.LinearLayout.setChildFrame (LinearLayout.java:1742)
  at android.widget.LinearLayout.layoutVertical (LinearLayout.java:1585)
  at android.widget.LinearLayout.onLayout (LinearLayout.java:1494)
  at android.view.View.layout (View.java:18014)
  at android.view.ViewGroup.layout (ViewGroup.java:5911)
  at android.widget.RelativeLayout.onLayout (RelativeLayout.java:1080)
  at android.view.View.layout (View.java:18014)
  at android.view.ViewGroup.layout (ViewGroup.java:5911)
  at android.support.v4.widget.DrawerLayout.onLayout (DrawerLayout.java:1171)
  at android.view.View.layout (View.java:18014)
  at android.view.ViewGroup.layout (ViewGroup.java:5911)
  at android.widget.FrameLayout.layoutChildren (FrameLayout.java:344)
  at android.widget.FrameLayout.onLayout (FrameLayout.java:281)
  at android.view.View.layout (View.java:18014)
  at android.view.ViewGroup.layout (ViewGroup.java:5911)
  at com.android.internal.widget.ActionBarOverlayLayout.onLayout (ActionBarOverlayLayout.java:493)
  at android.view.View.layout (View.java:18014)
  at android.view.ViewGroup.layout (ViewGroup.java:5911)
  at android.widget.FrameLayout.layoutChildren (FrameLayout.java:344)
  at android.widget.FrameLayout.onLayout (FrameLayout.java:281)
  at com.android.internal.policy.PhoneWindow$DecorView.onLayout (PhoneWindow.java:3175)
  at android.view.View.layout (View.java:18014)
  at android.view.ViewGroup.layout (ViewGroup.java:5911)
  at android.view.ViewRootImpl.performLayout (ViewRootImpl.java:2784)
  at android.view.ViewRootImpl.performTraversals (ViewRootImpl.java:2477)
  at android.view.ViewRootImpl.doTraversal (ViewRootImpl.java:1544)
  at android.view.ViewRootImpl$TraversalRunnable.run (ViewRootImpl.java:7616)
  at android.view.Choreographer$CallbackRecord.run (Choreographer.java:911)
  at android.view.Choreographer.doCallbacks (Choreographer.java:686)
  at android.view.Choreographer.doFrame (Choreographer.java:622)
  at android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:897)
  at android.os.Handler.handleCallback (Handler.java:739)
  at android.os.Handler.dispatchMessage (Handler.java:95)
  at android.os.Looper.loop (Looper.java:148)
  at android.app.ActivityThread.main (ActivityThread.java:7422)
  at java.lang.reflect.Method.invoke (Method.java)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1230)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1120)
Caused by: java.lang.reflect.InvocationTargetException: 
  at java.lang.reflect.Constructor.newInstance (Constructor.java)
  at android.view.LayoutInflater.createView (LayoutInflater.java:631)
  at com.android.internal.policy.PhoneLayoutInflater.onCreateView (PhoneLayoutInflater.java:58)
  at android.view.LayoutInflater.onCreateView (LayoutInflater.java:706)
  at android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:774)
  at android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:716)
  at android.view.LayoutInflater.rInflate (LayoutInflater.java:847)
  at android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:810)
  at android.view.LayoutInflater.inflate (LayoutInflater.java:527)
  at android.view.LayoutInflater.inflate (LayoutInflater.java:429)
  at us.emanon.timecard.MyWeekRecyclerViewAdapter.onCreateViewHolder (MyWeekRecyclerViewAdapter.java:36)
  at us.emanon.timecard.MyWeekRecyclerViewAdapter.onBindViewHolder (MyWeekRecyclerViewAdapter.java:16)
  at us.emanon.timecard.MyWeekRecyclerViewAdapter.onCreateViewHolder (MyWeekRecyclerViewAdapter.java:16)
  at us.emanon.timecard.MyWeekRecyclerViewAdapter.access$000 (MyWeekRecyclerViewAdapter.java:16)
  at android.support.v7.widget.RecyclerView$Adapter.createViewHolder (RecyclerView.java:6685)
  at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline (RecyclerView.java:5869)
  at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition (RecyclerView.java:5752)
  at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition (RecyclerView.java:5748)
  at android.support.v7.widget.LinearLayoutManager$LayoutState.next (LinearLayoutManager.java:2232)
  at android.support.v7.widget.LinearLayoutManager.layoutChunk (LinearLayoutManager.java:1559)
  at android.support.v7.widget.LinearLayoutManager.fill (LinearLayoutManager.java:1519)
  at android.support.v7.widget.LinearLayoutManager.onLayoutChildren (LinearLayoutManager.java:614)
  at android.support.v7.widget.RecyclerView.dispatchLayoutStep2 (RecyclerView.java:3812)
  at android.support.v7.widget.RecyclerView.dispatchLayout (RecyclerView.java:3529)
  at android.support.v7.widget.RecyclerView.onLayout (RecyclerView.java:4082)
  at android.view.View.layout (View.java:18014)
  at android.view.ViewGroup.layout (ViewGroup.java:5911)
  at android.support.constraint.ConstraintLayout.onLayout (ConstraintLayout.java:1855)
  at android.view.View.layout (View.java:18014)
  at android.view.ViewGroup.layout (ViewGroup.java:5911)
  at android.widget.LinearLayout.setChildFrame (LinearLayout.java:1742)
  at android.widget.LinearLayout.layoutVertical (LinearLayout.java:1585)
  at android.widget.LinearLayout.onLayout (LinearLayout.java:1494)
  at android.view.View.layout (View.java:18014)
  at android.view.ViewGroup.layout (ViewGroup.java:5911)
  at android.widget.RelativeLayout.onLayout (RelativeLayout.java:1080)
  at android.view.View.layout (View.java:18014)
  at android.view.ViewGroup.layout (ViewGroup.java:5911)
  at android.support.v4.widget.DrawerLayout.onLayout (DrawerLayout.java:1171)
  at android.view.View.layout (View.java:18014)
  at android.view.ViewGroup.layout (ViewGroup.java:5911)
  at android.widget.FrameLayout.layoutChildren (FrameLayout.java:344)
  at android.widget.FrameLayout.onLayout (FrameLayout.java:281)
  at android.view.View.layout (View.java:18014)
  at android.view.ViewGroup.layout (ViewGroup.java:5911)
  at com.android.internal.widget.ActionBarOverlayLayout.onLayout (ActionBarOverlayLayout.java:493)
  at android.view.View.layout (View.java:18014)
  at android.view.ViewGroup.layout (ViewGroup.java:5911)
  at android.widget.FrameLayout.layoutChildren (FrameLayout.java:344)
  at android.widget.FrameLayout.onLayout (FrameLayout.java:281)
  at com.android.internal.policy.PhoneWindow$DecorView.onLayout (PhoneWindow.java:3175)
  at android.view.View.layout (View.java:18014)
  at android.view.ViewGroup.layout (ViewGroup.java:5911)
  at android.view.ViewRootImpl.performLayout (ViewRootImpl.java:2784)
  at android.view.ViewRootImpl.performTraversals (ViewRootImpl.java:2477)
  at android.view.ViewRootImpl.doTraversal (ViewRootImpl.java:1544)
  at android.view.ViewRootImpl$TraversalRunnable.run (ViewRootImpl.java:7616)
  at android.view.Choreographer$CallbackRecord.run (Choreographer.java:911)
  at android.view.Choreographer.doCallbacks (Choreographer.java:686)
  at android.view.Choreographer.doFrame (Choreographer.java:622)
  at android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:897)
  at android.os.Handler.handleCallback (Handler.java:739)
  at android.os.Handler.dispatchMessage (Handler.java:95)
  at android.os.Looper.loop (Looper.java:148)
  at android.app.ActivityThread.main (ActivityThread.java:7422)
  at java.lang.reflect.Method.invoke (Method.java)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1230)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1120)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 
  at android.content.res.StringBlock.get (StringBlock.java:66)
  at android.content.res.XmlBlock$Parser.getPooledString (XmlBlock.java:459)
  at android.content.res.TypedArray.loadStringValueAt (TypedArray.java:1167)
  at android.content.res.TypedArray.getString (TypedArray.java:197)
  at android.widget.TextView.<init> (TextView.java:1374)
  at android.widget.TextView.<init> (TextView.java:957)
  at android.widget.TextView.<init> (TextView.java:953)
  at java.lang.reflect.Constructor.newInstance (Constructor.java)
  at android.view.LayoutInflater.createView (LayoutInflater.java:631)
  at com.android.internal.policy.PhoneLayoutInflater.onCreateView (PhoneLayoutInflater.java:58)
  at android.view.LayoutInflater.onCreateView (LayoutInflater.java:706)
  at android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:774)
  at android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:716)
  at android.view.LayoutInflater.rInflate (LayoutInflater.java:847)
  at android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:810)
  at android.view.LayoutInflater.inflate (LayoutInflater.java:527)
  at android.view.LayoutInflater.inflate (LayoutInflater.java:429)
  at us.emanon.timecard.MyWeekRecyclerViewAdapter.onCreateViewHolder (MyWeekRecyclerViewAdapter.java:36)
  at us.emanon.timecard.MyWeekRecyclerViewAdapter.onBindViewHolder (MyWeekRecyclerViewAdapter.java:16)
  at us.emanon.timecard.MyWeekRecyclerViewAdapter.onCreateViewHolder (MyWeekRecyclerViewAdapter.java:16)
  at us.emanon.timecard.MyWeekRecyclerViewAdapter.access$000 (MyWeekRecyclerViewAdapter.java:16)
  at android.support.v7.widget.RecyclerView$Adapter.createViewHolder (RecyclerView.java:6685)
  at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline (RecyclerView.java:5869)
  at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition (RecyclerView.java:5752)
  at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition (RecyclerView.java:5748)
  at android.support.v7.widget.LinearLayoutManager$LayoutState.next (LinearLayoutManager.java:2232)
  at android.support.v7.widget.LinearLayoutManager.layoutChunk (LinearLayoutManager.java:1559)
  at android.support.v7.widget.LinearLayoutManager.fill (LinearLayoutManager.java:1519)
  at android.support.v7.widget.LinearLayoutManager.onLayoutChildren (LinearLayoutManager.java:614)
  at android.support.v7.widget.RecyclerView.dispatchLayoutStep2 (RecyclerView.java:3812)
  at android.support.v7.widget.RecyclerView.dispatchLayout (RecyclerView.java:3529)
  at android.support.v7.widget.RecyclerView.onLayout (RecyclerView.java:4082)
  at android.view.View.layout (View.java:18014)
  at android.view.ViewGroup.layout (ViewGroup.java:5911)
  at android.support.constraint.ConstraintLayout.onLayout (ConstraintLayout.java:1855)
  at android.view.View.layout (View.java:18014)
  at android.view.ViewGroup.layout (ViewGroup.java:5911)
  at android.widget.LinearLayout.setChildFrame (LinearLayout.java:1742)
  at android.widget.LinearLayout.layoutVertical (LinearLayout.java:1585)
  at android.widget.LinearLayout.onLayout (LinearLayout.java:1494)
  at android.view.View.layout (View.java:18014)
  at android.view.ViewGroup.layout (ViewGroup.java:5911)
  at android.widget.RelativeLayout.onLayout (RelativeLayout.java:1080)
  at android.view.View.layout (View.java:18014)
  at android.view.ViewGroup.layout (ViewGroup.java:5911)
  at android.support.v4.widget.DrawerLayout.onLayout (DrawerLayout.java:1171)
  at android.view.View.layout (View.java:18014)
  at android.view.ViewGroup.layout (ViewGroup.java:5911)
  at android.widget.FrameLayout.layoutChildren (FrameLayout.java:344)
  at android.widget.FrameLayout.onLayout (FrameLayout.java:281)
  at android.view.View.layout (View.java:18014)
  at android.view.ViewGroup.layout (ViewGroup.java:5911)
  at com.android.internal.widget.ActionBarOverlayLayout.onLayout (ActionBarOverlayLayout.java:493)
  at android.view.View.layout (View.java:18014)
  at android.view.ViewGroup.layout (ViewGroup.java:5911)
  at android.widget.FrameLayout.layoutChildren (FrameLayout.java:344)
  at android.widget.FrameLayout.onLayout (FrameLayout.java:281)
  at com.android.internal.policy.PhoneWindow$DecorView.onLayout (PhoneWindow.java:3175)
  at android.view.View.layout (View.java:18014)
  at android.view.ViewGroup.layout (ViewGroup.java:5911)
  at android.view.ViewRootImpl.performLayout (ViewRootImpl.java:2784)
  at android.view.ViewRootImpl.performTraversals (ViewRootImpl.java:2477)
  at android.view.ViewRootImpl.doTraversal (ViewRootImpl.java:1544)
  at android.view.ViewRootImpl$TraversalRunnable.run (ViewRootImpl.java:7616)
  at android.view.Choreographer$CallbackRecord.run (Choreographer.java:911)
  at android.view.Choreographer.doCallbacks (Choreographer.java:686)
  at android.view.Choreographer.doFrame (Choreographer.java:622)
  at android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:897)
  at android.os.Handler.handleCallback (Handler.java:739)
  at android.os.Handler.dispatchMessage (Handler.java:95)
  at android.os.Looper.loop (Looper.java:148)
  at android.app.ActivityThread.main (ActivityThread.java:7422)
  at java.lang.reflect.Method.invoke (Method.java)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1230)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1120)

MyWeekRecyclerView

line 16:    public class MyWeekRecyclerViewAdapter extends RecyclerView.Adapter<MyWeekRecyclerViewAdapter.ViewHolder> {

        @SuppressWarnings("unused")
        private final static String TAG = MyWeekRecyclerViewAdapter.class.getSimpleName();
        private final List<WorkDay> mValues;

        private final WeekFragment.OnWeekFragmentInteractionListener mListener;

        private final DateTimeFormatter mDateFormat = DateTimeFormat.forPattern("M/d");
        private final DateTimeFormatter mDayFormat = DateTimeFormat.forPattern("EEEE");

        MyWeekRecyclerViewAdapter(Week week, WeekFragment.OnWeekFragmentInteractionListener listener) {
            mValues = week.getDays();
            mListener = listener;
        }

        @NonNull
        @Override
line 36:        public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
            View view = LayoutInflater.from(parent.getContext())
                    .inflate(R.layout.fragment_week, parent, false);
            return new ViewHolder(view);
        }

        @Override
        public void onBindViewHolder(@NonNull final ViewHolder holder, int position) {
            holder.mWorkDay = mValues.get(position);
            holder.mDateView.setText(mDateFormat.withLocale(Locale.getDefault()).print(holder.mWorkDay.getStartDate()));
            holder.mWeekDay.setText(mDayFormat.withLocale(Locale.getDefault()).print(holder.mWorkDay.getStartDate()));
            holder.mContentView.setHours(mValues.get(position).getTotalMinutesWithLunch());

            holder.mView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (null != mListener) {
                        // Notify the active callbacks interface (the activity, if the
                        // fragment is attached to one) that an item has been selected.
                        mListener.onWeekFragmentInteraction(holder.mWorkDay);
                    }
                }
            });
        }

WeekFragment

public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_week_list2, container, false);

    TextView title = view.findViewById(R.id.week_title_tv);
    mTotal = view.findViewById(R.id.week_hours_total);

    mWeek = mDataSource.getNewWeek(mYear, mDay);
    Context context = view.getContext();
    mRecyclerView = view.findViewById(R.id.list);
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context);
    linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    mRecyclerView.setLayoutManager(linearLayoutManager);
    mRecyclerView.setAdapter(new MyWeekRecyclerViewAdapter(mWeek, mListener));
    LocalDate weekStart = new LocalDate().withYear(mYear).withDayOfYear(mDay);
    WorkWeekStart start = new WorkWeekStart(getActivity(), weekStart);
    title.setText(String.format("%s - %s", start.startOfWorkWeek().toString("M/d/yy"), start.startOfWorkWeek().plusDays(6).toString("M/d/yy")));
    mTotal.setHours(mWeek.getHoursMinusLunch());
    return view;
}

到目前为止,这只是从Android 6.0(Marshmallow)出现,而是出现在许多不同的设备上。我已经尝试为每个参数传递null(这不可能发生)并发送非常糟糕的数据(再次,不会发生)并且无法重现它。我已经在模拟器中尝试了它,甚至找到了一个旧手机并且在它上面闪了6.0而没有运气。

0 个答案:

没有答案