0
這和我從sqlite表成功填充可展開列表視圖一樣。MonoDroid SimpleExpandableListAdapter
public class Today : ExpandableListActivity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
IList<IDictionary<string, object>> parent = new IList<IDictionary<string,object>>();
IList<IList<IDictionary<string, object>>> child = new IList<IList<IDictionary<string,object>>>();
External inst = new External();
var connection = inst.conn();
var c = connection.CreateCommand();
c.CommandText = "Select Distinct Store From Calls";
SqliteDataReader dr = c.ExecuteReader();
if (dr.HasRows)
while (dr.Read())
{
IDictionary<string, object> pItem = new IDictionary<string,object>();
pItem.Add("Store", dr[0].ToString());
parent.Add(pItem);
}
dr.Close();
int cnt = parent.Count();
if (cnt > 0)
{
IList<IDictionary<string, object>> children = new IList<IDictionary<string, object>>();
foreach(IDictionary<string, object> d in parent)
{
c.CommandText = "Select CallNumber From Calls Where Store = '" + d.Values + "'";
dr = c.ExecuteReader();
while (dr.Read())
{
IDictionary<string, object> childItem = new IDictionary<string, object>();
childItem.Add("Call", dr[0].ToString());
children.Add(childItem);
}
dr.Close();
}
child.Add(children);
}
SimpleExpandableListAdapter adapter = new SimpleExpandableListAdapter(this, parent, Android.Resource.Layout.SimpleExpandableListItem1, new string[] { "Store" }, new int[] { Android.Resource.Id.Text1, Android.Resource.Id.Text2 }, child, Android.Resource.Layout.SimpleExpandableListItem2, new string[] { "CallNumber" }, new int[] { Android.Resource.Id.Text1, Android.Resource.Id.Text2 });
SetListAdapter(adapter);
}
}
這將引發以下異常:
- 無法創建抽象類或接口「System.Collections.Generic.IDictionary
<string,object>
」 X2的實例 - 無法創建抽象的一個實例類或接口'System.Collections.Generic.IList
<System.Collections.Generic.IDictionary
X2
這些異常真的不說我爲什麼不能創建這些實例,或給我提供任何我不正確做法的線索。