Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Binding - Changed Class to Interface

$
0
0

Hello everyone. First of all, i'm not a very experienced programmer, so i'll probably talk some nonsense here.

I'm binding a jar to use in my project. To use jar in java, the programmer wrote this:

access.addItem(itemId, new DataCallback() 
{
@Override
public void changed(Item item, ItemState state) 
{
System.out.println(state);
}

The point here is the DataCallBack class. The method changed is called everytime that itemId changes. In java, works like a charm.

Then, after the binding, the DataCallBack class changed to a C# interface. Why this happened ? So, i tried to create a class and implemented this DataCallBack interface:

    public class CallBack : IDataCallback
    {
        public void Changed(Item p0, ItemState p1)
        {
            throw new NotImplementedException();
        }

        IntPtr IJavaObject.Handle
        {
            get;
            set;
        }

        void IDisposable.Dispose()
        {

        }
    }   

Then i converted the java code from the beggining into this:

access.AddItem(itemId, new CallBack());

But the Changed method is not called, like in java, but no errors are thrown, so i might be forgeting somenthing here.

Can anybody give me a clue here ?

Thanks a lot !!!


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>