2012-03-16 91 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();