Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

list on the android listview ios sample sqlite data

$
0
0

i developed a sqlite app on ios and its simple to show on listview, but i try to port android, i got a question

public void SqList(string databaseFile,string opinion) { try { if (!File.Exists (databaseFile)) {

           return;

        }
        //end if

        // Connect to database
        using (SqliteConnection sqlCon = new SqliteConnection (String.Format ("Data Source = {0}", databaseFile))) 
        {

           sqlCon.Open ();

           using (SqliteCommand sqlCom = new SqliteCommand (sqlCon)) 
           {
              sqlCom.CommandText="SELECT * FROM Personel";

              using (SqliteDataReader dbReader = sqlCom.ExecuteReader ())
              {
                 if (dbReader.HasRows)
                 {
                    int i;
                    // Advance through each row
                    tasks = new List<TaskX> ();
                    while (dbReader.Read ())
                    {     
                       TaskX dtask= new TaskX() {Id = Convert.ToInt16( dbReader["ID"]), 
                          Name = String.Format (Convert.ToString (dbReader["UserName"])),
                          Notes=String.Format ( Convert.ToString (dbReader["Password"])),
                          Done=false};
                       tasks.Add(dtask);
                    };
                 }
              };
              TableView.Source = new RootTableSource(tasks.ToArray ());
           }
           sqlCon.Close ();
        }
     } catch (Exception ex) 
     { }
  }

this is ios sample but i checked the android version

if(this._taskListView != null)
         {
            this._taskListView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => {
               var taskDetails = new Intent (this, typeof (TaskDetailsScreen));
               taskDetails.PutExtra ("TaskID", this._tasks[e.Position].ID);
               this.StartActivity (taskDetails);
            };
         }

its shows on listview

i guess i convert this line to

TableView.Source = new RootTableSource(tasks.ToArray ());

Android

thanks for help


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>