refresh table after sync from web

HalukmyHalukmy ✭✭TRMember ✭✭

i download datas from web but i have to push page back and forward for list views, is there simple refresh list view?

Posts

  • JooFerreira.2190JooFerreira.2190 ✭✭ PTUniversity ✭✭

    @haluk‌

    Can you explain better what you need to do?

    Best Regards

  • GuillermoGutierrezGuillermoGutierrez ✭✭✭ ESMember ✭✭✭

    If by 'list view' you mean UITableView you can call the ReloadData method to refresh the contents from the data source.

  • HalukmyHalukmy ✭✭ TRMember ✭✭

    @JoaoFerreira‌
    using (SqliteConnection sqlCon = new SqliteConnection (String.Format ("Data Source = {0}", SQLitePath)))
    {
    sqlCon.Open ();

            using (SqliteCommand sqlCom = new SqliteCommand (sqlCon)) 
            {
              sqlCom.CommandText="SELECT * FROM EMIRLER";
    
    
              using (SqliteDataReader dbReader = sqlCom.ExecuteReader ())
              {
                if (dbReader.HasRows)
                {
                  // Advance through each row
                  taskx = new List<AdminT> ();
                  while (dbReader.Read ())
                  {     
                    AdminT dtask= new AdminT() {
                      Id = Convert.ToInt16( dbReader["ID"]), 
                      Baslik =  (string)dbReader["Baslik"],
                      icerik = (string)dbReader["Mesaj"],
                      imgurl  = (string)dbReader["ImgUrl"]
    
    
                    };
                    taskx.Add(dtask);
                  };
                }
              };
              haberEmir.Source = new AdminTableSource(taskx.ToArray ());
            }
            sqlCon.Close ();
          }
    

    this is uitableview component

    when i async download data, i have to change page for list new view but is there async refresh?

  • JooFerreira.2190JooFerreira.2190 ✭✭ PTUniversity ✭✭

    Hi,

    Add this line

    haberEmir.ReloadData();

    after this haberEmir.Source = new AdminTableSource(taskx.ToArray ());

    But be careful, if you're running this code in another thread, you have to use InvokeOnMainThread ()

  • HalukmyHalukmy ✭✭ TRMember ✭✭

    @JoaoFerreira‌
    gorevler.Source = new TableSource(tasks.ToArray ());
    // gorevler.ReloadData();
    // InvokeOnMainThread(delegate{
    // gorevler.Source = new TableSource(tasks.ToArray ());
    //
    // gorevler.ReloadData();

    i also tried this but after download sync data not refreshas on page

    its simply a button clicks;

    get and save data

    but not refresh

  • JooFerreira.2190JooFerreira.2190 ✭✭ PTUniversity ✭✭
    edited February 2014

    @haluk‌

    Show me your AdminTableSource please

  • HalukmyHalukmy ✭✭ TRMember ✭✭

    @JoaoFerreira‌ here is it

      public class TableSource: UITableViewSource
       {
          string cellIdentifier = "taskcellc";
          PersonelX[] tableItemsX;
    
    
          public TableSource(PersonelX[] items)
          {
             tableItemsX = items;
          }
    
          public override int RowsInSection (UITableView tableview, int section)
          {
             return tableItemsX.Length;
          }
    
          public override UITableViewCell GetCell (UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath)
          {
             // in a Storyboard, Dequeue will ALWAYS return a cell, 
             UITableViewCell cell = tableView.DequeueReusableCell (cellIdentifier);
          cell.TextLabel.Text = tableItemsX[indexPath.Row].PersonelAd +" "+tableItemsX[indexPath.Row].Gorev ; 
    
          if (tableItemsX[indexPath.Row].Goruldu == true)
            {           
            cell.BackgroundColor = UIColor.White;
              cell.Accessory = UITableViewCellAccessory.Checkmark;
    
            } else
            {
            cell.Accessory = UITableViewCellAccessory.DetailButton;
            cell.BackgroundColor = UIColor.LightGray;
    
            }
             return cell;
          }
    
          public PersonelX GetItem(int ID) {
             return tableItemsX[ID];
          }
    
       }
    
Sign In or Register to comment.