Skip to content
This repository has been archived by the owner. It is now read-only.
This repository has been archived by the owner. It is now read-only.

MvxPreferenceFragmentCompat inconsistent crashing #312

Description

@woody1987

Steps to reproduce

  1. Create a MvxPreferenceFragmentCompat, without using a custom layout.

Expected behavior

Should display preferences

Actual behavior

Display preferences the first couple of times, then will seemingly at random through an error

ERROR : UNHANDLED : Java.Lang.RuntimeException: Content has view with id attribute 'R.id.list_container' that is not a ViewGroup class at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <234a083d9eb54b4982c0c529c70a7497>:0 at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualObjectMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x000a8] in <1acc3b4387144f52bf5acc1663c645b1>:0 at Android.Runtime.JNIEnv.CallNonvirtualObjectMethod (System.IntPtr jobject, System.IntPtr jclass, System.IntPtr jmethod, Android.Runtime.JValue* parms) [0x00015] in <c306cfd08ef940588fcd9c545f29d86b>:0 at Android.Support.V4.App.Fragment.OnCreateView (Android.Views.LayoutInflater inflater, Android.Views.ViewGroup container, Android.OS.Bundle savedInstanceState) [0x000c0] in <013f8eacb1954462a2f9d5f677673fee>:0 at MvvmCross.Droid.Support.V7.Preference.MvxEventSourcePreferenceFragmentCompat.OnCreateView (Android.Views.LayoutInflater inflater, Android.Views.ViewGroup container, Android.OS.Bundle savedInstanceState) [0x00014] in <45009b09ade2492080dee1e0295253f4>:0

My class:

[Register("xxxx.views.fragments.SettingsFragment")]
public class SettingsFragment : MvxPreferenceFragmentCompat
{
	public new SettingsViewModel ViewModel
	{
		get { return (SettingsViewModel)base.ViewModel; }
		set { base.ViewModel = value; }
	}

	public override void OnCreate(Bundle savedInstanceState)
	{
		base.OnCreate(savedInstanceState);
		HasOptionsMenu = true;
	}

	public override void OnResume()
	{
		base.OnResume();
	}

	public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
	{
		var view = base.OnCreateView(inflater, container, savedInstanceState);
		
		//setting up bindings

		return view;
	}

	public override void OnCreatePreferences(Bundle savedInstanceState, string rootKey)
	{
		AddPreferencesFromResource(Resource.Xml.preferences);
	}

	public override void OnCreateOptionsMenu(IMenu menu, MenuInflater inflater)
	{
		inflater.Inflate(Resource.Menu.settings_menu, menu);
		base.OnCreateOptionsMenu(menu, inflater);
	}

	public override void OnPrepareOptionsMenu(IMenu menu)
	{
		for (int i = 0; i < menu.Size(); i++)
			menu.GetItem(i).SetShowAsAction(ShowAsAction.Always | ShowAsAction.WithText);
		
		base.OnPrepareOptionsMenu(menu);
	}

	public override bool OnOptionsItemSelected(IMenuItem item)
	{
		switch (item.ItemId)
		{
			case Resource.Id.action_help:
				Help.ShowHelp(Activity, "Help/Settings_Help.htm");
				return true;
		}

		return base.OnOptionsItemSelected(item);
	}
}

Configuration

Version: 4.3.0
Happens on Android 4+

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions