Reputation: 1135
I am trying to use ActionBar in MVVMCross Xamarin Adroid app. I am able to load layout in fragment fine issue is context always pointing to MainView rather than view of the layout. I tried to change the context but getting exception for resource. Error is
Java.Lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference
Code snippet
public class LocationFragment : Fragment { public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
//View view = inflater.Inflate(Resource.Layout.Location, null);
View view = inflater.CloneInContext(new LocationView().BaseContext).Inflate(Resource.Layout.Location, null);
return view;
}
}
One of Android native developer told me I can't change the context as view always drive from MainActivity. If thats right how could I use this with my view?
Upvotes: 0
Views: 615
Reputation: 3559
ActionBar is deprecated. You should probably use Toolbar, which MvvmCross provides samples for including fragment support: https://github.com/MvvmCross/MvvmCross-AndroidSupport/tree/master/Samples
Upvotes: 1