This is my updated project, i'm able to display data (json) through Api in the ListView but i am not able to filter that data through Search bar. I tried lots of thing but i can't solve. So can any one please solve my problem. Im new in this field #Thanks.
I tried this link:-
https://www.syntaxismyui.com/xamarin-forms-searchbar-recipe/
https://blog.verslu.is/xamarin/finding-nemo-implementing-xamarin-forms-searchbar/
NewsFeedPage.cs:->
using System;
using Xamarin.Forms;
using System.Collections.ObjectModel;
using System.Net.Http;
using Newtonsoft.Json.Linq;
using System.Diagnostics;
using Newtonsoft.Json;
using System.Collections.Generic;
namespace Searchbarr
{
public class NewsFeedPage : ContentPage
{
public static ObservableCollection<string> items { get; set; }
public NewsFeedPage ()
{
Title = "Searchbar";
SearchBar sb = new SearchBar{
Placeholder="Type here to search" ,
};
items = new ObservableCollection<string> ();
ListView lstView = new ListView ();
lstView.ItemsSource = items;
//------------------------Get NewsFeed API----------------------//
var client = new HttpClient ();
client.BaseAddress = new Uri ("http://hallpassapi.jamsocialapps.com");
var result = client.GetAsync ("http://hallpassapi.jamsocialapps.com/api/NewsFeed/GetNewsFeed?order_by=desc").Result;
string resultContent = result.Content.ReadAsStringAsync ().Result;
var bob = JObject.Parse (resultContent);
var asd = JsonConvert.SerializeObject (bob["responselist"]);
var questionsList = JsonConvert.DeserializeObject<List<Question>>(asd);
foreach(var question in questionsList)
{
Debug.WriteLine("Question 3 "+question.Feed);
items.Add (question.Feed);
}
Content = new StackLayout (){
Padding = new Thickness (0, 35, 0, 0),
Spacing = 3,
BackgroundColor = Color.White,
Orientation = StackOrientation.Vertical,
Children = {
sb,
lstView,
}
};
}
}
}
Another class:-
Question.cs:->
using System;
using Xamarin.Forms;
using System.Collections.Generic;
using System.Net.Http;
using Newtonsoft.Json.Linq;
using System.Diagnostics;
namespace Searchbarr
{
public class Question
{
public string Feed { get; set;}
}
}