Buton click and update listView with new data

Hello everyone. i have got a 7 button and 1 listview in my fragment. i want to cahange my listView data when i click any button. i wrote some codes but always come to defaul data, not change every click.

`var btn1 = view.FindViewById(Resource.Id.button1);
var btn2 = view.FindViewById(Resource.Id.button2);
var btn3 = view.FindViewById(Resource.Id.button3);
var btn4 = view.FindViewById(Resource.Id.button4);
var btn5 = view.FindViewById(Resource.Id.button5);
var btn6 = view.FindViewById(Resource.Id.button6);
var btn7 = view.FindViewById(Resource.Id.button7);
_streamList = view.FindViewById(Resource.Id.listView);

LoadStream(day);

btn1.Click += delegate { LoadStream(1); };
btn2.Click += delegate { LoadStream(2); };
btn3.Click += delegate { LoadStream(3); };
btn4.Click += delegate { LoadStream(4); };
btn5.Click += delegate { LoadStream(5); };
btn6.Click += delegate { LoadStream(6); };
btn7.Click += delegate { LoadStream(7); };

public void LoadStream(int _day)
{
_todayStreamList = TvStream.GetStreamRoot("http://abc.com/?a="+_day);

        this._streamList.Adapter = null;
        _streamList.Adapter = new StreamListAdapter(this, _todayStreamList);
       //((BaseAdapter)this._streamList.Adapter).NotifyDataSetChanged();
    }`

thank you.

Answers

  • wonderWomanwonderWoman USMember
    var btn1 = view.FindViewById(Resource.Id.button1);
     var btn2 = view.FindViewById(Resource.Id.button2); 
    var btn3 = view.FindViewById(Resource.Id.button3); 
    var btn4 = view.FindViewById(Resource.Id.button4); 
    var btn5 = view.FindViewById(Resource.Id.button5); 
    var btn6 = view.FindViewById(Resource.Id.button6); 
    var btn7 = view.FindViewById(Resource.Id.button7);
     _streamList = view.FindViewById(Resource.Id.listView);
    
    LoadStream(day);
    
    btn1.Click += delegate { LoadStream(1); }; 
    btn2.Click += delegate { LoadStream(2); }; 
    btn3.Click += delegate { LoadStream(3); }; 
    btn4.Click += delegate { LoadStream(4); }; 
    btn5.Click += delegate { LoadStream(5); };
     btn6.Click += delegate { LoadStream(6); }; 
    btn7.Click += delegate { LoadStream(7); };
    
    public void LoadStream(int _day) 
    { 
    _todayStreamList = TvStream.GetStreamRoot("http://exapmlesite.com/json?a="+_day);
    
            this._streamList.Adapter = null;
            _streamList.Adapter = new StreamListAdapter(this, _todayStreamList);
           //((BaseAdapter)this._streamList.Adapter).NotifyDataSetChanged();
        }`
    
  • wonderWomanwonderWoman USMember

    i did it ! i redefine my class and no problem, everthing is good now. thank you everyone.

    _todayStreamList = new List<TvStream.Schedule>();

Sign In or Register to comment.