2012-03-16 81 views
0

我有一个用Mono Android编写的应用程序,它有一个窗体并在列表中显示数据。该应用程序工作正常。 但现在我想另一个字段添加到布局:Android.Content.Res.Resources + NotFoundException

<TextView 
      android:id="@+id/textDeliveryNo" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="12345" 
      android:textStyle="bold" 
      android:textColor="@color/title" 
      android:textSize="20px" 

    /> 

我修改了活动acordingly将此字段设置为它的值:

//Get our object for this position   
    var item = items[position];       
    var view = (convertView ??     
       context.LayoutInflater.Inflate(     
        Resource.Layout.DeliveriesListItem,        parent,     
        false)) as LinearLayout;    

    //Find references to each subview in the list item's view   
    var imageItem = view.FindViewById(Resource.Id.imageItem) as ImageView; 
    var textDeliveryNo = view.FindViewById(Resource.Id.textDeliveryNo) as TextView; 
    var textDeliveryName = view.FindViewById(Resource.Id.textDeliveryName) as TextView; 
    var textDeliveryAddress = view.FindViewById(Resource.Id.textDeliveryAddress) as TextView; 
    var textDeliveryCityAndZip = view.FindViewById(Resource.Id.textDeliveryCityAndZip) as TextView; 

    //Assign this item's values to the various subviews    
    imageItem.SetImageResource(item.Image); 

ERROR LINE> textDeliveryNo.SetText(item.DeliveryNo, TextView.BufferType.Normal); textDeliveryName.SetText(item.LocationName, TextView.BufferType.Normal); textDeliveryAddress.SetText(item.Address, TextView.BufferType.Normal); textDeliveryCityAndZip.SetText(item.City + ", " + item.PostalCode, TextView.BufferType.Normal);

调试器停止在错误LINE的错误: Android.Content.Res.Resources + NotFoundException:

我尝试清理,重建项目...重新启动VS 20 10但没有。 如果我评论这行,它会编译,但它会显示“12345”或任何我把android:text属性。

我会apreciate任何帮助,我可以得到。 非常感谢!

回答

1

您正在使用的SetText的重载需要一个资源ID,当你只是想将它设置为一个字符串(恰好是一个数字)。

使用这个代替:

txtDeliveryNo.Text = item.DeliveryNo.ToString();

相关问题