首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SimpleCursorAdapter IllegalArgumentException

SimpleCursorAdapter IllegalArgumentException
EN

Stack Overflow用户
提问于 2013-03-08 09:29:45
回答 1查看 240关注 0票数 1

我目前正在使用Visual Studio2010和C#进行安卓编程。编译时出现错误:Unhandled Exception: Java.Lang.IllegalArgumentException:有人可以解决这个问题吗?

下面是我的代码:

代码语言:javascript
复制
         void GetCursorView()
          {
             Android.Database.ICursor icTemp = sql.GetRecordCursor();
             if (icTemp != null)
             {
             icTemp.MoveToFirst();
             ListView lvTemp = FindViewById(Resource.Id.lvtemp);
             string[] from = new string[] { "id", "fname", "age", "addr" };
              int[] to = new int[] {
              Resource.Id.t1,
              Resource.Id.t2,
              Resource.Id.t3,
              Resource.Id.t4
                };
          // creating a SimpleCursorAdapter to fill ListView object.
             SimpleCursorAdapter scaTemp = new SimpleCursorAdapter(this,Resource.Layout.recordview, icTemp, from, to); //error on this line
                     lvTemp.Adapter = scaTemp;
                            }
                        else
                         {
                         text.Text = sql.Message;
                            }
                      }

下面是我的XML:

代码语言:javascript
复制
    <?xml version="1.0" encoding="utf-8"?>
    <AbsoluteLayout
        android:id="@+id/widget35"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        xmlns:android="http://schemas.android.com/apk/res/android">
      <ListView
        android:id="@+id/lvtemp"
        android:layout_width="276dp"
        android:layout_height="147dp"
        android:background="#ff999999"
        android:padding="100dp"
        android:layout_marginTop="10dp"
        android:layout_marginBottom="10dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:drawSelectorOnTop="true"
        android:gravity="center"
        android:layout_x="22dp"
        android:layout_y="0dp" 
        />
      <TextView
        android:id="@+id/t1"
        android:layout_width="268dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:layout_marginBottom="10dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:hint="ID"
        android:layout_x="27dp"
        android:layout_y="157dp" />
      <TextView
        android:id="@+id/t2"
        android:layout_width="264dp"
        android:layout_height="22dp"
        android:hint="Name"
        android:layout_x="30dp"
        android:layout_y="204dp" />
      <TextView
        android:id="@+id/t3"
        android:layout_width="261dp"
        android:layout_height="wrap_content"
        android:hint="age"
        android:layout_x="31dp"
        android:layout_y="244dp" />
      <TextView
        android:id="@+id/t4"
        android:layout_width="269dp"
        android:layout_height="wrap_content"
        android:hint="Address"
        android:layout_x="30dp"
        android:layout_y="282dp" />
      <

        Button
            android:id="@+id/b1"
            android:layout_width="182dp"
            android:layout_height="wrap_content"
            android:text="OK"
            android:layout_x="77dp"
            android:layout_y="324dp" />

    </AbsoluteLayout>
EN

回答 1

Stack Overflow用户

发布于 2013-03-08 13:48:15

我认为不是

代码语言:javascript
复制
SimpleCursorAdapter scaTemp = new SimpleCursorAdapter(this,Resource.Layout.recordview, icTemp, from, to); 

代码语言:javascript
复制
SimpleCursorAdapter scaTemp = new SimpleCursorAdapter(this, icTemp,Resource.Layout.recordview, from, to); 
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15285195

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档