2014-06-26 116 views
1

我試圖將端口achrtengine庫移植到Xamarin.Droid。將achartengine移植到Xamarin

我所做的是: -

1 - 創建一個新的Android的Java綁定圖書館項目。 2-將添加到Jars文件夾的.jar。 3-設置構建動作EmbededJar

,但得到這個錯誤: - 此行

'Pan': member names cannot be the same as their enclosing type 

public event EventHandler Pan { 
      add { 
       global::Java.Interop.EventHelper.AddEventHandler<global::Org.Achartengine.Tools.IPanListener, global::Org.Achartengine.Tools.IPanListenerImplementor>(
         ref weak_implementor_AddPanListener, 
         __CreateIPanListenerImplementor, 
         AddPanListener, 
         __h => __h.Handler += value); 
      } 
      remove { 
       global::Java.Interop.EventHelper.RemoveEventHandler<global::Org.Achartengine.Tools.IPanListener, global::Org.Achartengine.Tools.IPanListenerImplementor>(
         ref weak_implementor_AddPanListener, 
         global::Org.Achartengine.Tools.IPanListenerImplementor.__IsEmpty, 
         RemovePanListener, 
         __h => __h.Handler -= value); 
      } 
     } 

我想這是因爲類名是潘太

// Metadata.xml XPath class reference: path="/api/package[@name='org.achartengine.tools']/class[@name='Pan']" 
    [global::Android.Runtime.Register ("org/achartengine/tools/Pan", DoNotGenerateAcw=true)] 
    public partial class Pan : global::Org.Achartengine.Tools.AbstractTool { 

更新: -

我插入這條線來解決這個問題

<attr path="/api/package[@name='org.achartengine.tools']/class[@name='Pan']" name="name">PanClass</attr> 

更改類的名稱。

,但得到這些錯誤: -

Error CS0019: Operator '==' cannot be applied to operands of type 'AChartEngine.Renderer.XYSeriesRenderer.FillOutsideLine.Type' and 'System.Type' (CS0019) (AChartEngineBindings) 

Error CS1503: Argument 2: cannot convert from 'string' to 'System.IntPtr' (CS1503) (AChartEngineBindings) 

有誰知道如何解決這個問題?!

任何幫助都很有用。 謝謝。

回答

3

我發現這裏的答案:http://forums.xamarin.com/discussion/1935/achartengine-org-jar-binding-error

你應該添加那些元數據:

<attr path="/api/package[@name='org.achartengine.renderer']/class[@name='XYSeriesRenderer.FillOutsideLine']/method[@name='getType' and count(parameter)=0]" name="managedName">GetBehaviorType</attr> 
    <attr path="/api/package[@name='org.achartengine.renderer']/class[@name='XYSeriesRenderer.FillOutsideLine.Type']" name="managedName">FillOutsideLineBehaviorType</attr> 
    <attr path="/api/package[@name='org.achartengine']" name="managedName">AChartEngine</attr> 
    <attr path="/api/package[@name='org.achartengine.chart']" name="managedName">AChartEngine.Chart</attr> 
    <attr path="/api/package[@name='org.achartengine.model']" name="managedName">AChartEngine.Model</attr> 
    <attr path="/api/package[@name='org.achartengine.renderer']" name="managedName">AChartEngine.Renderer</attr> 
    <attr path="/api/package[@name='org.achartengine.tools']" name="managedName">AChartEngine.Tools</attr> 
    <attr path="/api/package[@name='org.achartengine.util']" name="managedName">AChartEngine.Util</attr> 

    <attr path="/api/package[@name='org.achartengine.tools']/class[@name='Pan']/method[@name='addPanListener']" name="eventName">PanEvent</attr> 

到FillOutsideLine.GetType()和FillOutsideLine.Type重命名爲GetBehaviorType()和FillOutsideLineBehaviorType。

並更改事件名稱。

我已經將源代碼添加到github中,例如:https://github.com/mostafa-elabady/Xamarin_achartengine