在xamarin.android中列出sqlite数据库表

时间:2018-07-26 18:17:17

标签: xamarin.android

我要列出所有sqlite数据库表,

当我尝试列出表格内容时,它仅显示表格的第一列。

AXML页面:;

  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
  android:layout_width="fill_parent"
    android:layout_height="wrap_content"
   android:layout_marginTop="0dp"
  android:clickable="true"
  android:divider="#b5b5b5"
  android:dividerHeight="1dp"
    android:id="@+id/listView1" />

cs页面:

string dpPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "BookmarkSqlite.db3");  
        var db = new SQLiteConnection(dpPath);
          var data = db.Table<BookmarkSqliteTable>(); 


        foreach (var listing in data)

        {  var from = new string[]{ listing.SiteName + "----" + listing.SiteUrl }; 

            //var from = fromm.ToList();

            ListView listtable = (ListView)FindViewById(Resource.Id.listView1);
            listtable.Adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleListItem1, from);
        }

    }

0 个答案:

没有答案