I have an activity with an actionbar. When I click my actionbar "More" tab to load a ListFragment, my app always crashes with an alert saying "Unfortunately "my app" has stopped" The error message I get in my VS output log is: "java.lang.RuntimeException: Content has view with id attribute 'android.R.id.list' that is not a ListView class"
I'd like to use the ActivityListItem or even the SimpleListItem1 found here: http://docs.xamarin.com/guides/android/user_interface/working_with_listviews_and_adapters/part_3_-_customizing_a_listview's_appearance/
I got it working for a ListActivity but need it as a ListFragment Thanks in advance for any help.
public class More : ListFragment { View view; string[] items; public override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Create your fragment here }
public override void OnActivityCreated(Bundle savedInstanceState)
{
base.OnActivityCreated(savedInstanceState);
items = new string[] { "Row 1", "Row 2" };
//ListAdapter = new ArrayAdapter<String>(Activity, Android.Resource.Layout.SimpleListItem1, items);
ListAdapter = new ArrayAdapter<String>(Activity, Android.Resource.Layout.ActivityListItem, items);
//ListView myList1 = view.FindViewById<ListView>(Resource.Id.myList1);
}
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
//view = inflater.Inflate(Resource.Layout.More, container, false);
//view = inflater.Inflate(Android.Resource.Layout.SimpleListItem1, container, false);
view = inflater.Inflate(Android.Resource.Layout.ActivityListItem, container, false);
return view;
}
public override void OnListItemClick(ListView l, View v, int position, long id)
{
var title = items[position];
Android.Widget.Toast.MakeText(Activity, title, Android.Widget.ToastLength.Short).Show();
}
}