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

MvxPreferenceFragmentCompat inconsistent crashing #312

Open
woody1987 opened this issue Nov 1, 2016 · 1 comment
Open

MvxPreferenceFragmentCompat inconsistent crashing #312

woody1987 opened this issue Nov 1, 2016 · 1 comment

Comments

@woody1987
Copy link

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+

@Cheesebaron
Copy link
Member

Not sure what is going on here. We don't inflate any layouts ourselves or manipulate any views. This is just a simple wrapper around PreferenceFragmentCompat which exposes a couple of events.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants