I am new to Xamarin and I am trying to refresh my MainActivity from itself. I read a lot of forums about that but I still can't find any solution. My problem is that I need to do the refreshing from another method, not within the onCreate() method.
My MainActivity is a listview and I want to reload the whole activity in order to refresh the listview. I need to reload the whole activity because in my situation I can't use NotifyDataSetChanged() because the changes I am making to the listview are not within the onCreate() method and not in a new activity neither. I have a CAB menu from where the user has the option to delete selected note from the listview. I am using the NotifyDataSetChanged() method in my onResume() method and it's working perfectly when I am making the changes to my listview in another activity but it's not working when I am making them from the current activity because then the onResume() method is not being called .
I've tried doing it like this:
Intent refresh = new Intent(this,typeof(MainActivity));
refresh.AddFlags(ActivityFlags.NoAnimation);
Finish();
StartActivity(refresh);
but it's giving me NullPointerException on the first row already .. And the exception I think is the "this". So I tried it differently : instead of using "this" I am using - Intent refresh = new Intent(context ,typeof(MainActivity)); where context=this in the onCreate() method. But in this way it's still giving me a NullPointerException but this time on the row - StartActivity(refresh) ..
Thanks in advance ! :)
0 comments:
Post a Comment