Reputation: 231
I was following a youtube video that teaches us how to develop app with Xamarin Studio. I followed the exact thing that the guy did. But currently I'm getting the error
"ListView is a 'namespace' but is used like a type"
Here's my code
int count = 1;
private List<string> mItem;
private ListView mListView;
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
mListView = FindViewById<ListView> (Resource.Id.mylistview);
mItem = new List<string> ();
//Add Items
mItem.Add ("Tom");
mItem.Add ("Bob");
mItem.Add ("Jack");
ArrayAdapter<string> adapter = new ArrayAdapter<string> (this, Android.Resource.Layout.SimpleListItem1, mItem);
mListView.Adapter = adapter;
}
Upvotes: 2
Views: 2086
Reputation: 43304
Because you named your project ListView, whenever you use ListView
in your code, it thinks youre referring to the namespace, because that is the name of your project. Then you cannot use ListView as a type anymore.
Pick a different project name and it should work. Keep in mind to never name projects after keywords or type names.
Upvotes: 4