publicclass MyAdapter : BaseAdapter<string> { private List<string> l = new List<string>(); private Context context; public MyAdapter(Context context) { this.context = context; } publicoverridestringthis[int position] { get { returnthis.l[position]; } } publicoverrideint Count { get { return l.Count; } } publicoverridelong GetItemId(int position) { return position; } publicoverride View GetView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = View.Inflate(this.context, Resource.Layout.MyLayout, parent); } convertView.FindViewById<TextView>(Resource.Id.textViewContent).Text = this[position]; return convertView; } publicvoid Add(string i) { this.l.Add(i); this.NotifyDataSetChanged(); } }
これでInflateのところで例外が出る。因みにMyLayout.axmlはこんな感じ。
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical"android:layout_width="fill_parent"android:layout_height="fill_parent"><TextViewandroid:text="項目"android:textAppearance="?android:attr/textAppearanceLarge"android:layout_width="match_parent"android:layout_height="wrap_content"android:id="@+id/textView1" /><TextViewandroid:text="Small Text"android:textAppearance="?android:attr/textAppearanceSmall"android:layout_width="match_parent"android:layout_height="wrap_content"android:id="@+id/textViewContent" /></LinearLayout>
ん~。謎。