1
如果你還記得從xamarin樣品tasky演示,我們可以連接的任務(如ID,標題,分)與顯示數據MonoDroid的列表視圖(從MonoTouch的移植)
TableView.Source = new RootTableSource(tasks.ToArray());
在MonoDroid的,它有點複雜。我使用SQLite,在這裏我的MonoTouch的SQLite代碼
{
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());
}
,我注意到的代碼行取源值
protected override void OnResume()
{
base.OnResume();
this._tasks = Tasky.BL.Managers.TaskManager.GetTasks();
// create our adapter
this._taskList = new Adapters.TaskListAdapter(this, this._tasks);
//Hook up our adapter to our ListView
this._taskListView.Adapter = this._taskList;
}
任何方式來顯示像ID sqlite的值,用戶名android上的列表視圖?謝謝