In my Requirement having wizard step.So If I am in Second Step.And pressing back.And Now I m in first wizard.And pressing next so it recreate activity.that's why I have put it into OnCreate.
When I go to that activity for first time then My Adapter notifydatasetchange work properly but when I'm go back and again goes to same activity Notifydatasetchange() not working means onbindviewholder not called.
Even I have Tried to set adapter again but it's not still called.This is my code.What I have missing? Any help is appreciated!
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.ProposalInviteOwnersView);
_lstviewNearByPeople = FindViewById<RecyclerView>(Resource.Id.lstviewNearByPeople);
_layoutmanager = new LinearLayoutManager(this, LinearLayoutManager.Horizontal, false);
_lstviewNearByPeople.HasFixedSize = true;
_lstviewNearByPeople.SetLayoutManager(_layoutmanager);
BindtoNearByAdapter();
}
public void BindtoNearByAdapter()
{
try
{
if (GlobalConst.LstNearByPeople.Count > 0)
{
_lstNearByPeople = new List<Owners>();
_lstNearByPeople.AddRange(GlobalConst.LstNearByPeople);
if(_nearByCollaboratorAdapter==null)
{
_lstviewNearByPeople.Visibility = ViewStates.Visible;
_nearByCollaboratorAdapter = new NearByCollaboratorAdapter(this, _lstNearByPeople, this, mlastPosition);
_lstviewNearByPeople.SetAdapter(_nearByCollaboratorAdapter);
}
else
{
_nearByCollaboratorAdapter.updateItems(_lstNearByPeople);
}
}
else
{
_noNearByDevicelayout.Visibility = ViewStates.Visible;
_lstviewNearByPeople.Visibility = ViewStates.Gone;
}
}
catch (System.Exception ex)
{
Core.Helpers.GlobalLogic.createCrashReport(ex);
Toast.MakeText(this, ex.Message.ToString(), ToastLength.Short).Show();
}
}
public class NearByCollaboratorAdapter : RecyclerView.Adapter
{
public List<Owners> _lstNearByPeople;
readonly ISelectCollaborator _listner;
readonly Activity _context;
protected int mLastPosition;
public NearByCollaboratorAdapter(Activity context, List<Owners> lstNearByPeople, ISelectCollaborator listner, int _mLastPosition)
{
_lstNearByPeople = lstNearByPeople;
_context = context;
_listner = listner;
mLastPosition = _mLastPosition;
}
public override int ItemCount => _lstNearByPeople.Count;
public void updateItems(List<Owners> lstNearByPeople)
{
_lstNearByPeople.Clear();
_lstNearByPeople.AddRange(lstNearByPeople);
this.NotifyDataSetChanged();
}
}