After returning to create a new entry to mainActivity refresh display properly, the problem is that once again, click on the entry changes after return, show is initially after the new state, and then modify the interface to switch back and forth with the list of interface entries state between the initial state and normal state repeatedly switch,,,
This is to create a new empty entry after the state of the
This is click on the switching activity after modified
Modify the state of the return, and then can follow the activity of the entry form constantly switching between above and below conversion
That is, list the activity every time suspended after entry state switching between normal and abnormal, and whether RecycleView reuse pan, We had several days, can only ask for help, the following is the refresh method code: /* * * update interface */ Private void updateUI () { MemoryLab MemoryLab=MemoryLab. Get (getActivity ());//create a singleton object MemoryLab List Memories.=memoryLab getMemories ();//get the Memory list If (memories. The size ()!=0) { MNoOneTextView. SetVisibility (View. GONE);//set the data for empty interface hint view } If (mAdapter==null) { MAdapter=new MemoryAdapter (memories);//this list of initialization mAdapter MAdapter. SetHasStableIds (true); MMemoryRecyclerView. SetAdapter (mAdapter);//will mMemoryRecyclerView associated with mAdapter } else { MAdapter. NotifyItemChanged (mposition); } }
This is custom Adapter class overriding methods: @ Override Public void onBindViewHolder (@ NonNull MemoryHolder holder, final int position) { The Memory of the Memory=mMemories. Get (position); Holder. The bind (memory); }
@ Override Public int getItemCount () { Return mMemories. The size (); }
@ Override Public int getItemViewType (int position) { Return the position; } @ Override Public long getItemId (int position) { Return the position; }
This is custom ViewHolder class of the bind () method: /* * * always call the bind (Memory) method to display each Memory * * @ param memory */ Public void bind the Memory Memory) { MMemory=memory; MTitleCheckBox. SetText (" "+ mMemory getTitle ()); SetTime (mMemory getDate ());//set the title and time
MTitleCheckBox. SetChecked (mMemory isSolved ());
MTitleCheckBox. SetOnClickListener (new CompoundButton. An OnClickListener () { @ Override Public void onClick (View View) { MMemory setSolved (! MMemory. IsSolved ()); } }); }