Forum Xamarin.Android

Errors with list views

Hello again, stuck again.

Been working with a custom list adapter and had it working not 2 minutes prior to it now returning an error. Here is my full code that i am using:

namespace RapStation


[Activity (Theme= "@android:style/Theme.NoTitleBar")]           

public class HomeActivity : ListActivity


    NewsObject[] news;

    protected override void OnCreate (Bundle bundle)


        base.OnCreate (bundle);

        SetContentView (Resource.Layout.Main);

        string content = Intent.GetStringExtra ("newslist");

        news = JsonConvert.DeserializeObject<NewsObject[]>(content);

        Console.Out.WriteLine ("Now: \r\n {0}", news[0].title);

        var listNews = FindViewById<ListView> (Resource.Id.list);

        listNews.Adapter = new HomeScreenAdapter (this, news);

        var Listen = FindViewById<Button> (Resource.Id.btnListen);

        var Shows  = FindViewById<Button> (Resource.Id.btnShows);

        Listen.Click += (sender, e) => {

            var second = new Intent (this, typeof(RadioActivity));

            StartActivity (second);



    protected override void OnListItemClick(ListView l, View v, int position, long id)


        var t = news[position];

        var second = new Intent (this, typeof(NewsActivity));

        second.PutExtra ("newsTitle", t.title);

        second.PutExtra ("newsBody", t.body);

        second.PutExtra ("newsCaption", t.caption);

        second.PutExtra ("newsDate", t.datestamp);

        StartActivity (second);

        //Android.Widget.Toast.MakeText(this, t, Android.Widget.ToastLength.Short).Show();

        Console.WriteLine("Clicked on " + t.title);




the OnListItemClick is what I was working on and added last which probably had something to do with my new error. The error in question is highlighting the line
SetContentView (resource.layout.main);
and telling me that the content must contain a listview with an attribute id of

Anyone know what I did to break this?


  • KlutchSCKlutchSC USMember

    All good, fixed and done!

  • HarshadcseHarshadcse USMember ✭✭✭

    Hii, @JosephAndrews

    I have to use this code :

    base.OnCreate (bundle);
       RequestWindowFeature (WindowFeatures.NoTitle);
       SetContentView (Resource.Layout.Property);
       listview = FindViewById<ListView> (Resource.Id.listProperty);
       var ResName = JArray.Parse (Intent.GetStringExtra ("responseText"));
       Console.WriteLine ("{0}", ResName.Count);
       for (int i=0; i<ResName.Count; i++) {
            tableItems.Add (new TableItem () {
               PropertyName="" + ResName [i] ["name"],
               ShortName= "" +ResName [i] ["sho_name"], 
               PropertyUri= "" +ResName [i] ["uri"],
               Rightarrow = Resource.Drawable.dgreenarrow
     listview.Adapter = new PropertyAdapter (this, tableItems);
     listview.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => {
           var t = tableItems [e.Position];
           Console.WriteLine (t.PropertyUri);
           TableItem.InquiriesUri= t.PropertyUri;
           StartActivity (typeof(ListActivity));


Sign In or Register to comment.