Forum Xamarin.Android

Search inside ListAdapter

Hey everyone,

I would really appreciate if someone could help me with search inside Listadapter. I couldn't get it to work.

Adapter Class

                class NoteAdapter:ArrayAdapter
    {
        private Activity activity;


        public NoteAdapter(Activity activity, Context context, int textViewResourceId, object[] objects)
            : base(context, textViewResourceId, objects)
        {
            this.activity = activity;
        }

        public override Android.Views.View GetView(int position, Android.Views.View convertView, Android.Views.ViewGroup parent)
        {
            var item = (UserModel)this.GetItem(position);

            var view = (convertView ?? activity.LayoutInflater.Inflate(Resource.Layout.NoteListRow, parent, false)) as LinearLayout;

            view.FindViewById<TextView>(Resource.Id.name).Text = item.Name.Replace("\n", " ");

            return view;
        }
    }

Activity

    public class SessionsActivity : ListActivity
    {

        UserDetails noterep = new UserDetails();
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            PopulateList();
        }

        public void PopulateList()
        {
            var notes = noterep.GetAllNotes();
            var adapter = new NoteAdapter(this, this, Resource.Layout.NoteListRow, notes.ToArray());
            ListAdapter = adapter;
        }
    }

Any ideas are welcome,
Thanks.

Posts

Sign In or Register to comment.