This is a migrated thread and some comments may be shown as answers.

RadDataForm basic usage issues

1 Answer 10 Views
DataForm - Xamarin.Android
This is a migrated thread and some comments may be shown as answers.
Headygains
Top achievements
Rank 1
Veteran
Headygains asked on 30 Dec 2019, 09:50 PM

I'm attempting to add a RadDataForm to a fragment:

this.form = new RadDataForm(this.Context);
var entity = new Models.Inventory.ConveyanceReceipt();
this.form.SetEntity(entity);
this._root.AddView(this.form);

The line where i call .SetEntity(object) throws a Java.Lang null pointer exception:

Unhandled Exception:
Java.Lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Class.isInterface()' on a null object reference.

 

The entity model is: 

 

public class ConveyanceReceipt : Java.Lang.Object
{
    [DataFormProperty(Label="Conveyance ID", Index = 1, Required = true)]
    public string Tracker { get; set; }
 
    [DataFormProperty(Label = "Scan Time", Index = 0, ReadOnly = true)]
    public DateTime Time { get; set; } = DateTime.Now;
}

 

I kept it very simple and I really am trying to wrap my head around why I can't get the basic example past SetEntity();

 

Any help would be greatly appreciated, is there some initialization that I'm not doing? I tried tracking down the isInterface getter and couldn't locate a value for it in debugger.

1 Answer, 1 is accepted

Sort by
0
Didi
Telerik team
answered on 02 Jan 2020, 10:59 AM

Hello Dalton,

Thank you for the provided code.

I have tested it in our native Xamarin.Android DataForm examples and I reproduced the exception on my side.

I have further research the case and I have found that the exception is thrown when Time property is from type DateTime. I have implemented the notify propertychanged interface to the business model and the error I got was : cannot convert System.DateTime to Java.Lang.Object. and then null pointer exception is thrown.

Solution:

I have tried different approaches and I have found the following solution:

- set the Time property to be of type long. When the ReadOnly attribute is set to true the setter for the associated property will be ignored and a viewer will be created instead of an editor. It works in scenario when the Time property is from type long. A sample example can be found at the followng link from our documentation:

https://docs.telerik.com/devtools/xamarin/nativecontrols/android/dataform/dataform-metadata

I hope this information will be helpful.

Regards,
Didi
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
DataForm - Xamarin.Android
Asked by
Headygains
Top achievements
Rank 1
Veteran
Answers by
Didi
Telerik team
Share this question
or